scope-agent-workbench 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/bridge/agent-email-relay.mjs +160 -160
  3. package/bridge/app-server-websocket-transport.mjs +219 -219
  4. package/bridge/archive/service.mjs +130 -130
  5. package/bridge/auth-profile-failover.mjs +58 -58
  6. package/bridge/auth-profile-manager.mjs +215 -215
  7. package/bridge/capacity-recovery.mjs +90 -90
  8. package/bridge/gpu-usage-history.mjs +322 -322
  9. package/bridge/local/history.mjs +20 -5
  10. package/bridge/plugins/aliyun-dlc/monitor.mjs +236 -236
  11. package/bridge/plugins/aliyun-dlc/probe.mjs +701 -701
  12. package/bridge/private-gateway.mjs +371 -371
  13. package/bridge/private-start.mjs +22 -22
  14. package/bridge/probes/app-server-handoff-probe.mjs +87 -87
  15. package/bridge/probes/app-server-writer-probe.mjs +69 -69
  16. package/bridge/probes/assistant-search-probe.mjs +321 -321
  17. package/bridge/probes/dialogue-probe.mjs +462 -462
  18. package/bridge/probes/history-probe.mjs +430 -345
  19. package/bridge/probes/new-session-preflight.mjs +14 -14
  20. package/bridge/probes/profile-cancel-probe.mjs +17 -17
  21. package/bridge/probes/profile-delete-probe.mjs +26 -26
  22. package/bridge/probes/profile-list-probe.mjs +114 -114
  23. package/bridge/probes/profile-write-probe.mjs +109 -109
  24. package/bridge/probes/raw-context-probe.mjs +51 -51
  25. package/bridge/probes/remote-probe.mjs +627 -626
  26. package/bridge/probes/submission-probe.mjs +2 -2
  27. package/bridge/probes/takeover-probe.mjs +326 -326
  28. package/bridge/probes/vscode-open-preflight.mjs +21 -21
  29. package/bridge/providers/claude-interactive.py +463 -341
  30. package/bridge/providers/cli-command.mjs +103 -103
  31. package/bridge/providers/conversations.mjs +231 -231
  32. package/bridge/providers/native-commands.py +38 -38
  33. package/bridge/providers/native-session-state.mjs +14 -14
  34. package/bridge/providers/native-session-state.py +96 -96
  35. package/bridge/providers/remote-job.py +130 -130
  36. package/bridge/remote-app-server-command.mjs +121 -121
  37. package/bridge/remote-directory-listing.mjs +148 -148
  38. package/bridge/rollout-summary.mjs +20 -2
  39. package/bridge/routes/dialogue.mjs +48 -3
  40. package/bridge/routes/models.mjs +312 -312
  41. package/bridge/server.mjs +3357 -3332
  42. package/bridge/session-attachments.mjs +150 -150
  43. package/bridge/session-catalog/agy-history.py +141 -2
  44. package/bridge/session-catalog/catalog.mjs +17 -0
  45. package/bridge/session-catalog/probe.py +1207 -331
  46. package/bridge/session-catalog/routes.mjs +6 -0
  47. package/bridge/start.mjs +205 -205
  48. package/bridge/state-persistence.mjs +9 -1
  49. package/bridge/tmux-session-control.mjs +29 -29
  50. package/bridge/vscode-opener.mjs +157 -157
  51. package/bridge/web-terminal.mjs +52 -52
  52. package/bridge/workbench/manager-context.mjs +51 -51
  53. package/bridge/workbench/service.mjs +301 -301
  54. package/dist/client/.vite/manifest.json +4 -4
  55. package/dist/client/assets/{index-Enu1x0PS.js → index-BMior55c.js} +2 -2
  56. package/dist/client/assets/{layout-segment-context-CmJzExWq.js → layout-segment-context-DjGudgXn.js} +1 -1
  57. package/dist/client/assets/page-CJqXlhDs.js +551 -0
  58. package/dist/client/assets/page-LYzRz6_S.css +1 -0
  59. package/dist/client/favicon.svg +6 -6
  60. package/dist/server/__vite_rsc_assets_manifest.js +8 -8
  61. package/dist/server/index.js +7 -7
  62. package/dist/server/ssr/__vite_rsc_assets_manifest.js +8 -8
  63. package/dist/server/ssr/assets/{page-CYYyCnKD.js → page-BB9Dri2u.js} +2416 -271
  64. package/dist/server/ssr/assets/page-LYzRz6_S.css +1 -0
  65. package/dist/server/ssr/index.js +1 -1
  66. package/dist/server/ssr/vinext-server.json +1 -1
  67. package/dist/server/vinext-server.json +1 -1
  68. package/dist/server/wrangler.json +1 -1
  69. package/lib/browser-snapshot-cache.js +53 -53
  70. package/lib/formula-preview.js +1 -1
  71. package/lib/incremental-snapshot.js +300 -300
  72. package/lib/markdown-math.js +151 -151
  73. package/lib/remote-links.js +95 -95
  74. package/lib/runtime-config.js +70 -70
  75. package/lib/session-filters.js +38 -38
  76. package/lib/ssh-config.js +26 -26
  77. package/lib/stable-order.js +39 -39
  78. package/lib/subagent-display-prefs.ts +130 -0
  79. package/package.json +1 -1
  80. package/scripts/agent-email-relay.mjs +104 -104
  81. package/scripts/email-notification-cli.mjs +28 -28
  82. package/scripts/enable-private-access.ps1 +109 -109
  83. package/scripts/fixtures/native-conversations.mjs +164 -6
  84. package/scripts/fixtures/workbench-conversations.mjs +475 -352
  85. package/scripts/preview-workbench.mjs +669 -669
  86. package/dist/client/assets/page-COBv6VWj.css +0 -1
  87. package/dist/client/assets/page-DVjU6VG_.js +0 -550
  88. package/dist/server/ssr/assets/page-COBv6VWj.css +0 -1
@@ -1,22 +1,22 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import { startPrivateGateway } from "./private-gateway.mjs";
4
-
5
- const repoRoot = path.resolve(
6
- path.dirname(fileURLToPath(import.meta.url)),
7
- "..",
8
- );
9
- const stateFile = path.join(repoRoot, ".scope", "private-access.json");
10
- const { server, host, port } = await startPrivateGateway({ stateFile });
11
-
12
- console.log(`[scope-private] gateway listening on http://${host}:${port}`);
13
- console.log(`[scope-private] access token is stored in ${stateFile}`);
14
- console.log("[scope-private] expose this loopback URL with Tailscale Serve; never use Funnel.");
15
-
16
- function stop() {
17
- server.close(() => process.exit(0));
18
- }
19
-
20
- process.on("SIGINT", stop);
21
- process.on("SIGTERM", stop);
22
-
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { startPrivateGateway } from "./private-gateway.mjs";
4
+
5
+ const repoRoot = path.resolve(
6
+ path.dirname(fileURLToPath(import.meta.url)),
7
+ "..",
8
+ );
9
+ const stateFile = path.join(repoRoot, ".scope", "private-access.json");
10
+ const { server, host, port } = await startPrivateGateway({ stateFile });
11
+
12
+ console.log(`[scope-private] gateway listening on http://${host}:${port}`);
13
+ console.log(`[scope-private] access token is stored in ${stateFile}`);
14
+ console.log("[scope-private] expose this loopback URL with Tailscale Serve; never use Funnel.");
15
+
16
+ function stop() {
17
+ server.close(() => process.exit(0));
18
+ }
19
+
20
+ process.on("SIGINT", stop);
21
+ process.on("SIGTERM", stop);
22
+
@@ -1,89 +1,89 @@
1
1
  /** Remote probe, kept independent of HTTP and local mutable state. */
2
- export const APP_SERVER_HANDOFF_PROBE = String.raw`
3
- import glob
4
- import json
5
- import os
6
- import re
7
- import sys
8
-
9
- pid = int(sys.argv[1])
10
- expected_rollout = os.path.realpath(sys.argv[2])
11
- expected_cwd = os.path.realpath(sys.argv[3])
12
-
13
- def fail(message, code=1):
14
- print(message, file=sys.stderr)
15
- raise SystemExit(code)
16
-
17
- def process_alive(target_pid):
18
- stat_path = f"/proc/{target_pid}/stat"
19
- try:
20
- with open(stat_path, "r", encoding="utf-8", errors="replace") as handle:
21
- fields = handle.read().split()
22
- return len(fields) > 2 and fields[2] != "Z"
23
- except Exception:
24
- return False
25
-
26
- def rollout_owners():
27
- owners = []
28
- for fd_path in glob.glob("/proc/[0-9]*/fd/*"):
29
- try:
30
- target = os.path.realpath(os.readlink(fd_path))
31
- except Exception:
32
- continue
33
- if target == expected_rollout:
34
- try:
35
- owners.append(int(fd_path.split("/")[2]))
36
- except Exception:
37
- pass
38
- return sorted(set(owners))
39
-
40
- def process_args(target_pid):
41
- try:
42
- with open(f"/proc/{target_pid}/cmdline", "rb") as handle:
43
- return [
44
- value.decode("utf-8", errors="replace")
45
- for value in handle.read().split(b"\x00")
46
- if value
47
- ]
48
- except Exception:
49
- return []
50
-
51
- def scope_app_server_owner(target_pid):
52
- args = process_args(target_pid)
53
- try:
54
- app_server_index = args.index("app-server")
55
- listen_index = args.index("--listen", app_server_index + 1)
56
- endpoint = args[listen_index + 1]
57
- except (ValueError, IndexError):
58
- return False
59
- control_dir = os.path.realpath(
60
- os.path.expanduser("~/.codex/app-server-control")
61
- )
62
- expected_prefix = "unix://" + control_dir + "/scope-"
63
- isolated_prefix = "unix://" + os.path.realpath(os.path.expanduser("~/.codex/scope-auth-profiles")) + "/"
64
- isolated_suffix = endpoint[len(isolated_prefix):] if endpoint.startswith(isolated_prefix) else ""
65
- return (endpoint.startswith(expected_prefix) and endpoint.endswith(".sock")) or bool(
66
- re.fullmatch(r"([A-Za-z0-9][A-Za-z0-9._-]{0,47})/home/app-server-control/scope-account-\1\.sock", isolated_suffix)
67
- )
68
-
69
- if not os.path.isdir(expected_cwd):
70
- fail(f"工作目录不存在:{expected_cwd}", 18)
71
-
72
- owners = rollout_owners()
73
- if pid > 0:
74
- fail("安全策略禁止终止活动 CLI/VS Code Session", 23)
75
- foreign_owners = [owner for owner in owners if not scope_app_server_owner(owner)]
76
- if foreign_owners:
77
- fail(
78
- "该 Session 已由 PID " + ",".join(map(str, foreign_owners)) + " 打开;请刷新页面",
79
- 17,
80
- )
81
-
82
- print(json.dumps({
83
- "ok": True,
84
- "killedPid": None,
85
- "forced": False,
86
- "cwd": expected_cwd,
87
- "reconnectedOwnerPids": owners,
88
- }, ensure_ascii=False, separators=(",", ":")))
2
+ export const APP_SERVER_HANDOFF_PROBE = String.raw`
3
+ import glob
4
+ import json
5
+ import os
6
+ import re
7
+ import sys
8
+
9
+ pid = int(sys.argv[1])
10
+ expected_rollout = os.path.realpath(sys.argv[2])
11
+ expected_cwd = os.path.realpath(sys.argv[3])
12
+
13
+ def fail(message, code=1):
14
+ print(message, file=sys.stderr)
15
+ raise SystemExit(code)
16
+
17
+ def process_alive(target_pid):
18
+ stat_path = f"/proc/{target_pid}/stat"
19
+ try:
20
+ with open(stat_path, "r", encoding="utf-8", errors="replace") as handle:
21
+ fields = handle.read().split()
22
+ return len(fields) > 2 and fields[2] != "Z"
23
+ except Exception:
24
+ return False
25
+
26
+ def rollout_owners():
27
+ owners = []
28
+ for fd_path in glob.glob("/proc/[0-9]*/fd/*"):
29
+ try:
30
+ target = os.path.realpath(os.readlink(fd_path))
31
+ except Exception:
32
+ continue
33
+ if target == expected_rollout:
34
+ try:
35
+ owners.append(int(fd_path.split("/")[2]))
36
+ except Exception:
37
+ pass
38
+ return sorted(set(owners))
39
+
40
+ def process_args(target_pid):
41
+ try:
42
+ with open(f"/proc/{target_pid}/cmdline", "rb") as handle:
43
+ return [
44
+ value.decode("utf-8", errors="replace")
45
+ for value in handle.read().split(b"\x00")
46
+ if value
47
+ ]
48
+ except Exception:
49
+ return []
50
+
51
+ def scope_app_server_owner(target_pid):
52
+ args = process_args(target_pid)
53
+ try:
54
+ app_server_index = args.index("app-server")
55
+ listen_index = args.index("--listen", app_server_index + 1)
56
+ endpoint = args[listen_index + 1]
57
+ except (ValueError, IndexError):
58
+ return False
59
+ control_dir = os.path.realpath(
60
+ os.path.expanduser("~/.codex/app-server-control")
61
+ )
62
+ expected_prefix = "unix://" + control_dir + "/scope-"
63
+ isolated_prefix = "unix://" + os.path.realpath(os.path.expanduser("~/.codex/scope-auth-profiles")) + "/"
64
+ isolated_suffix = endpoint[len(isolated_prefix):] if endpoint.startswith(isolated_prefix) else ""
65
+ return (endpoint.startswith(expected_prefix) and endpoint.endswith(".sock")) or bool(
66
+ re.fullmatch(r"([A-Za-z0-9][A-Za-z0-9._-]{0,47})/home/app-server-control/scope-account-\1\.sock", isolated_suffix)
67
+ )
68
+
69
+ if not os.path.isdir(expected_cwd):
70
+ fail(f"工作目录不存在:{expected_cwd}", 18)
71
+
72
+ owners = rollout_owners()
73
+ if pid > 0:
74
+ fail("安全策略禁止终止活动 CLI/VS Code Session", 23)
75
+ foreign_owners = [owner for owner in owners if not scope_app_server_owner(owner)]
76
+ if foreign_owners:
77
+ fail(
78
+ "该 Session 已由 PID " + ",".join(map(str, foreign_owners)) + " 打开;请刷新页面",
79
+ 17,
80
+ )
81
+
82
+ print(json.dumps({
83
+ "ok": True,
84
+ "killedPid": None,
85
+ "forced": False,
86
+ "cwd": expected_cwd,
87
+ "reconnectedOwnerPids": owners,
88
+ }, ensure_ascii=False, separators=(",", ":")))
89
89
  `;
@@ -1,72 +1,72 @@
1
1
  /** Remote probe, kept independent of HTTP and local mutable state. */
2
- export const APP_SERVER_WRITER_PROBE = String.raw`
3
- import glob
4
- import json
5
- import os
6
- import re
7
- import sys
8
-
9
- session_id = sys.argv[1]
10
- if not re.fullmatch(r"[A-Za-z0-9._-]{8,200}", session_id):
11
- print(json.dumps({"connectionKey": None, "error": "invalid session id"}))
12
- raise SystemExit(2)
13
-
14
- expected_lock = os.path.realpath(
15
- os.path.expanduser(f"~/.codex/thread-writer-locks/{session_id}.lock")
16
- )
17
- control_dir = os.path.realpath(os.path.expanduser("~/.codex/app-server-control"))
18
-
19
- def process_args(pid):
20
- try:
21
- with open(f"/proc/{pid}/cmdline", "rb") as handle:
22
- return [
23
- value.decode("utf-8", errors="replace")
24
- for value in handle.read().split(b"\x00")
25
- if value
26
- ]
27
- except Exception:
28
- return []
29
-
30
- owners = []
31
- for fd_path in (fd for proc in glob.glob("/proc/[0-9]*")
32
- if "app-server" in process_args(proc.rsplit("/", 1)[-1])
33
- for fd in glob.glob(proc + "/fd/*")):
34
- try:
35
- target = os.path.realpath(os.readlink(fd_path))
36
- except Exception:
37
- continue
38
- if target != expected_lock:
39
- continue
40
- try:
41
- owners.append(int(fd_path.split("/")[2]))
42
- except Exception:
43
- pass
44
-
45
- for pid in sorted(set(owners)):
46
- args = process_args(pid)
47
- try:
48
- app_server_index = args.index("app-server")
49
- listen_index = args.index("--listen", app_server_index + 1)
50
- endpoint = args[listen_index + 1]
51
- except (ValueError, IndexError):
52
- continue
53
- prefix = "unix://" + control_dir + "/scope-"
54
- if endpoint.startswith(prefix) and endpoint.endswith(".sock"):
55
- connection_key = endpoint[len(prefix):-len(".sock")]
56
- else:
57
- isolated_prefix = "unix://" + os.path.realpath(os.path.expanduser("~/.codex/scope-auth-profiles")) + "/"
58
- suffix = endpoint[len(isolated_prefix):] if endpoint.startswith(isolated_prefix) else ""
2
+ export const APP_SERVER_WRITER_PROBE = String.raw`
3
+ import glob
4
+ import json
5
+ import os
6
+ import re
7
+ import sys
8
+
9
+ session_id = sys.argv[1]
10
+ if not re.fullmatch(r"[A-Za-z0-9._-]{8,200}", session_id):
11
+ print(json.dumps({"connectionKey": None, "error": "invalid session id"}))
12
+ raise SystemExit(2)
13
+
14
+ expected_lock = os.path.realpath(
15
+ os.path.expanduser(f"~/.codex/thread-writer-locks/{session_id}.lock")
16
+ )
17
+ control_dir = os.path.realpath(os.path.expanduser("~/.codex/app-server-control"))
18
+
19
+ def process_args(pid):
20
+ try:
21
+ with open(f"/proc/{pid}/cmdline", "rb") as handle:
22
+ return [
23
+ value.decode("utf-8", errors="replace")
24
+ for value in handle.read().split(b"\x00")
25
+ if value
26
+ ]
27
+ except Exception:
28
+ return []
29
+
30
+ owners = []
31
+ for fd_path in (fd for proc in glob.glob("/proc/[0-9]*")
32
+ if "app-server" in process_args(proc.rsplit("/", 1)[-1])
33
+ for fd in glob.glob(proc + "/fd/*")):
34
+ try:
35
+ target = os.path.realpath(os.readlink(fd_path))
36
+ except Exception:
37
+ continue
38
+ if target != expected_lock:
39
+ continue
40
+ try:
41
+ owners.append(int(fd_path.split("/")[2]))
42
+ except Exception:
43
+ pass
44
+
45
+ for pid in sorted(set(owners)):
46
+ args = process_args(pid)
47
+ try:
48
+ app_server_index = args.index("app-server")
49
+ listen_index = args.index("--listen", app_server_index + 1)
50
+ endpoint = args[listen_index + 1]
51
+ except (ValueError, IndexError):
52
+ continue
53
+ prefix = "unix://" + control_dir + "/scope-"
54
+ if endpoint.startswith(prefix) and endpoint.endswith(".sock"):
55
+ connection_key = endpoint[len(prefix):-len(".sock")]
56
+ else:
57
+ isolated_prefix = "unix://" + os.path.realpath(os.path.expanduser("~/.codex/scope-auth-profiles")) + "/"
58
+ suffix = endpoint[len(isolated_prefix):] if endpoint.startswith(isolated_prefix) else ""
59
59
  match = re.fullmatch(r"([A-Za-z0-9][A-Za-z0-9._-]{0,47})/(?:home|scope-home)/app-server-control/scope-account-\1\.sock", suffix)
60
- if not match:
61
- continue
62
- connection_key = "account-" + match.group(1)
63
- if re.fullmatch(r"[A-Za-z0-9_.-]{1,100}", connection_key):
64
- print(json.dumps({
65
- "connectionKey": connection_key,
66
- "ownerPid": pid,
67
- "endpoint": endpoint,
68
- }, ensure_ascii=False, separators=(",", ":")))
69
- raise SystemExit(0)
70
-
71
- print(json.dumps({"connectionKey": None, "owners": sorted(set(owners))}))
60
+ if not match:
61
+ continue
62
+ connection_key = "account-" + match.group(1)
63
+ if re.fullmatch(r"[A-Za-z0-9_.-]{1,100}", connection_key):
64
+ print(json.dumps({
65
+ "connectionKey": connection_key,
66
+ "ownerPid": pid,
67
+ "endpoint": endpoint,
68
+ }, ensure_ascii=False, separators=(",", ":")))
69
+ raise SystemExit(0)
70
+
71
+ print(json.dumps({"connectionKey": None, "owners": sorted(set(owners))}))
72
72
  `;