josephrw commited on
Commit
fde6aba
Β·
verified Β·
1 Parent(s): f443ed2

Add camelCase GPT Action aliases: startSession, listTools, listReceipts, listArtifacts, listTerminals, apiHelp, getCapabilities, gateStatus

Browse files
app.py CHANGED
@@ -451,6 +451,125 @@ async def get_receipt(receipt_id: str):
451
  return {"id": row["id"], "kind": row["kind"], "workspace": row["workspace"], "summary": row["summary"], "sha256": row["sha256"], "created_at": row["created_at"], "data": json.loads(row["data_json"])}
452
 
453
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
454
  # ═══════════════════════════════════════════════════════════════
455
  # STATIC ARTIFACT SERVING (must be last β€” catches /artifact/* GETs)
456
  # ═══════════════════════════════════════════════════════════════
@@ -467,6 +586,8 @@ async def root():
467
  "version": "3.1.1",
468
  "endpoints": [
469
  "GET /health",
 
 
470
  "POST /terminal/run",
471
  "POST /python/run",
472
  "POST /session/create",
@@ -481,8 +602,15 @@ async def root():
481
  "POST /recall",
482
  "POST /tool/register",
483
  "GET /tools",
 
484
  "POST /tool/{name}",
485
  "GET /ledger/recent",
 
 
 
 
 
 
486
  "GET /receipt/{receipt_id}",
487
  ],
488
  }
 
451
  return {"id": row["id"], "kind": row["kind"], "workspace": row["workspace"], "summary": row["summary"], "sha256": row["sha256"], "created_at": row["created_at"], "data": json.loads(row["data_json"])}
452
 
453
 
454
+ # ═══════════════════════════════════════════════════════════════
455
+ # GPT ACTION ALIASES β€” camelCase routes for GPT Action compatibility
456
+ # ═══════════════════════════════════════════════════════════════
457
+ @app.get("/startSession")
458
+ async def alias_start_session_get(workspace: str = "default", cwd: str = "."):
459
+ sid = uuid.uuid4().hex[:12]
460
+ _ws_path(workspace, cwd)
461
+ now = datetime.now(timezone.utc).isoformat()
462
+ with DB_LOCK:
463
+ conn = _db()
464
+ conn.execute("INSERT INTO sessions VALUES (?,?,?,?,1)", (sid, workspace, cwd, now))
465
+ conn.commit()
466
+ conn.close()
467
+ return {"session_id": sid, "workspace": workspace, "cwd": cwd, "created_at": now}
468
+
469
+
470
+ @app.post("/startSession")
471
+ async def alias_start_session_post(req: SessionCreateRequest):
472
+ return await create_session(req)
473
+
474
+
475
+ @app.get("/listTools")
476
+ async def alias_list_tools():
477
+ return await list_tools()
478
+
479
+
480
+ @app.get("/listReceipts")
481
+ async def alias_list_receipts(limit: int = 50):
482
+ return await get_recent_ledger(limit)
483
+
484
+
485
+ @app.get("/listArtifacts")
486
+ async def alias_list_artifacts():
487
+ artifacts = []
488
+ if ARTIFACTS_DIR.exists():
489
+ for d in sorted(ARTIFACTS_DIR.iterdir())[:100]:
490
+ if d.is_dir():
491
+ meta_path = d / "meta.json"
492
+ if meta_path.exists():
493
+ meta = json.loads(meta_path.read_text())
494
+ artifacts.append(meta)
495
+ return {"artifacts": artifacts}
496
+
497
+
498
+ @app.get("/listTerminals")
499
+ async def alias_list_terminals():
500
+ with DB_LOCK:
501
+ conn = _db()
502
+ rows = conn.execute("SELECT session_id, workspace, cwd, created_at, active FROM sessions ORDER BY created_at DESC LIMIT 50").fetchall()
503
+ conn.close()
504
+ return {"terminals": [{"session_id": r["session_id"], "workspace": r["workspace"], "cwd": r["cwd"], "created_at": r["created_at"], "active": bool(r["active"])} for r in rows]}
505
+
506
+
507
+ @app.get("/apiHelp")
508
+ async def alias_api_help():
509
+ return {
510
+ "service": "Giant GPT Terminal Kernel",
511
+ "version": "3.1.1",
512
+ "operations": [
513
+ {"name": "health", "method": "GET", "path": "/health"},
514
+ {"name": "startSession", "method": "GET/POST", "path": "/startSession", "params": {"workspace": "string", "cwd": "string"}},
515
+ {"name": "runTerminal", "method": "POST", "path": "/terminal/run", "body": {"workspace": "string", "command": "string", "timeout_seconds": "int", "cwd": "string"}},
516
+ {"name": "runPython", "method": "POST", "path": "/python/run", "body": {"workspace": "string", "code": "string", "timeout_seconds": "int"}},
517
+ {"name": "runSession", "method": "POST", "path": "/session/run", "body": {"session_id": "string", "command": "string"}},
518
+ {"name": "writeFile", "method": "POST", "path": "/files/write", "body": {"workspace": "string", "path": "string", "content": "string"}},
519
+ {"name": "readFile", "method": "POST", "path": "/files/read", "body": {"workspace": "string", "path": "string"}},
520
+ {"name": "listFiles", "method": "POST", "path": "/files/list", "body": {"workspace": "string", "path": "string"}},
521
+ {"name": "workspaceTree", "method": "GET", "path": "/workspace/tree", "params": {"workspace": "string"}},
522
+ {"name": "compileArtifact", "method": "POST", "path": "/artifact/compile", "body": {"workspace": "string", "filename": "string", "content": "string"}},
523
+ {"name": "issueUrl", "method": "POST", "path": "/url/issue", "body": {"workspace": "string", "filename": "string", "content": "string"}},
524
+ {"name": "learn", "method": "POST", "path": "/learn", "body": {"topic": "string", "content": "string", "utility": "float"}},
525
+ {"name": "recall", "method": "POST", "path": "/recall", "body": {"query": "string", "limit": "int"}},
526
+ {"name": "registerTool", "method": "POST", "path": "/tool/register", "body": {"name": "string", "command_template": "string", "mode": "string"}},
527
+ {"name": "listTools", "method": "GET", "path": "/listTools"},
528
+ {"name": "invokeTool", "method": "POST", "path": "/tool/{name}", "body": {"workspace": "string", "args": "object"}},
529
+ {"name": "listReceipts", "method": "GET", "path": "/listReceipts"},
530
+ {"name": "listArtifacts", "method": "GET", "path": "/listArtifacts"},
531
+ {"name": "listTerminals", "method": "GET", "path": "/listTerminals"},
532
+ {"name": "getCapabilities", "method": "GET", "path": "/getCapabilities"},
533
+ {"name": "gateStatus", "method": "GET", "path": "/gateStatus"},
534
+ {"name": "getReceipt", "method": "GET", "path": "/receipt/{receipt_id}"},
535
+ ],
536
+ }
537
+
538
+
539
+ @app.get("/getCapabilities")
540
+ async def alias_get_capabilities():
541
+ return {
542
+ "capabilities": [
543
+ {"name": "terminal", "description": "Execute shell commands in a sandboxed workspace", "methods": ["POST /terminal/run", "POST /session/run"]},
544
+ {"name": "python", "description": "Execute Python code in a sandboxed workspace", "methods": ["POST /python/run"]},
545
+ {"name": "filesystem", "description": "Read, write, and list files in workspaces", "methods": ["POST /files/write", "POST /files/read", "POST /files/list", "GET /workspace/tree"]},
546
+ {"name": "artifacts", "description": "Compile and serve artifact files with stable URLs", "methods": ["POST /artifact/compile", "POST /url/issue", "GET /listArtifacts"]},
547
+ {"name": "memory", "description": "Store and recall persistent memory entries", "methods": ["POST /learn", "POST /recall"]},
548
+ {"name": "tools", "description": "Register and invoke dynamic custom tools", "methods": ["POST /tool/register", "GET /listTools", "POST /tool/{name}"]},
549
+ {"name": "receipts", "description": "SHA-256 hashed receipt ledger for all operations", "methods": ["GET /listReceipts", "GET /receipt/{id}"]},
550
+ {"name": "sessions", "description": "Create and manage persistent terminal sessions", "methods": ["GET /startSession", "POST /startSession", "GET /listTerminals"]},
551
+ ],
552
+ "limits": {
553
+ "timeout_seconds": 30,
554
+ "max_file_bytes": 20000000,
555
+ "max_stdout": 50000,
556
+ },
557
+ }
558
+
559
+
560
+ @app.get("/gateStatus")
561
+ async def alias_gate_status():
562
+ return {
563
+ "gate": "open",
564
+ "authenticated": True,
565
+ "rate_limit": "none",
566
+ "concurrent_sessions": "unlimited",
567
+ "workspace_isolation": True,
568
+ "path_traversal_protection": True,
569
+ "receipt_system": True,
570
+ }
571
+
572
+
573
  # ═══════════════════════════════════════════════════════════════
574
  # STATIC ARTIFACT SERVING (must be last β€” catches /artifact/* GETs)
575
  # ═══════════════════════════════════════════════════════════════
 
586
  "version": "3.1.1",
587
  "endpoints": [
588
  "GET /health",
589
+ "GET /startSession",
590
+ "POST /startSession",
591
  "POST /terminal/run",
592
  "POST /python/run",
593
  "POST /session/create",
 
602
  "POST /recall",
603
  "POST /tool/register",
604
  "GET /tools",
605
+ "GET /listTools",
606
  "POST /tool/{name}",
607
  "GET /ledger/recent",
608
+ "GET /listReceipts",
609
+ "GET /listArtifacts",
610
+ "GET /listTerminals",
611
+ "GET /apiHelp",
612
+ "GET /getCapabilities",
613
+ "GET /gateStatus",
614
  "GET /receipt/{receipt_id}",
615
  ],
616
  }
data/artifacts/5e9873df37b0efcf/meta.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "filename": "report.md",
3
+ "content_type": "text/markdown",
4
+ "workspace": "default",
5
+ "sha256": "5e9873df37b0efcf",
6
+ "created_at": "2026-07-27T14:46:31.520382+00:00"
7
+ }
data/artifacts/5e9873df37b0efcf/report.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Demo Report
2
+
3
+ Generated by Giant GPT Terminal Kernel.