@ran-sh/dsh-crew 0.3.0

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 (85) hide show
  1. package/.claude-plugin/marketplace.json +17 -0
  2. package/.claude-plugin/plugin.json +8 -0
  3. package/.mcp.json +8 -0
  4. package/LICENSE +21 -0
  5. package/README.de.md +359 -0
  6. package/README.es.md +359 -0
  7. package/README.fr.md +359 -0
  8. package/README.hi.md +359 -0
  9. package/README.id.md +359 -0
  10. package/README.ja.md +359 -0
  11. package/README.ko.md +359 -0
  12. package/README.md +360 -0
  13. package/README.pt.md +359 -0
  14. package/README.ru.md +359 -0
  15. package/README.th.md +359 -0
  16. package/README.tr.md +359 -0
  17. package/README.vi.md +359 -0
  18. package/README.zh-TW.md +359 -0
  19. package/README.zh.md +305 -0
  20. package/agents/ds-flash.md +26 -0
  21. package/agents/ds-pro.md +32 -0
  22. package/agents/ds-reviewer.md +23 -0
  23. package/agents/ds-worker.md +22 -0
  24. package/codex/agents/ds-flash.toml +30 -0
  25. package/codex/agents/ds-pro.toml +31 -0
  26. package/codex/agents/ds-reviewer.toml +28 -0
  27. package/codex/agents/ds-worker.toml +28 -0
  28. package/codex/prompts/dsh-config.md +3 -0
  29. package/codex/prompts/dsh-status.md +1 -0
  30. package/commands/config.md +11 -0
  31. package/commands/off.md +5 -0
  32. package/commands/on.md +5 -0
  33. package/commands/status.md +5 -0
  34. package/cordis.patch.yml +4 -0
  35. package/docs/images/dsh-crew-host.png +0 -0
  36. package/docs/images/dsh-crew-jobs.png +0 -0
  37. package/docs/images/dsh-crew-logo.png +0 -0
  38. package/docs/images/dsh-crew-overview.png +0 -0
  39. package/lib/client.js +2765 -0
  40. package/package.json +125 -0
  41. package/scripts/build-client.mjs +28 -0
  42. package/scripts/live-crew-smoke.mjs +39 -0
  43. package/scripts/live-policy-matrix.mjs +177 -0
  44. package/scripts/policy-probe.mjs +101 -0
  45. package/scripts/setup.mjs +294 -0
  46. package/scripts/smoke-real.mjs +110 -0
  47. package/scripts/smoke.mjs +78 -0
  48. package/scripts/verify-installer-fix.mjs +26 -0
  49. package/src/adaptive-routing.mjs +260 -0
  50. package/src/client/activation-summary.tsx +64 -0
  51. package/src/client/entry.tsx +236 -0
  52. package/src/client/index.tsx +1120 -0
  53. package/src/config-readiness.mjs +59 -0
  54. package/src/delivery.mjs +205 -0
  55. package/src/dsh-cli-runtime.mjs +251 -0
  56. package/src/failure-classification.mjs +172 -0
  57. package/src/hub/entry.mjs +98 -0
  58. package/src/hub/index.mjs +757 -0
  59. package/src/hub-client.mjs +132 -0
  60. package/src/hub-compatibility.mjs +49 -0
  61. package/src/i18n.mjs +19 -0
  62. package/src/install/cli.mjs +28 -0
  63. package/src/install/install-legacy.mjs +460 -0
  64. package/src/install/install.mjs +451 -0
  65. package/src/jobs.mjs +275 -0
  66. package/src/mcp-runtime.mjs +257 -0
  67. package/src/model-catalog.mjs +173 -0
  68. package/src/model-routing.mjs +391 -0
  69. package/src/multimodal.mjs +0 -0
  70. package/src/policy-legacy.mjs +830 -0
  71. package/src/policy.mjs +197 -0
  72. package/src/readiness-matrix.mjs +169 -0
  73. package/src/runtime-controls.mjs +90 -0
  74. package/src/runtime-identity.mjs +108 -0
  75. package/src/server.mjs +477 -0
  76. package/src/status-shard.mjs +52 -0
  77. package/src/structured-error-code.mjs +39 -0
  78. package/src/vision-route.mjs +138 -0
  79. package/src/workflow-runtime.mjs +567 -0
  80. package/src/workflow.mjs +160 -0
  81. package/src/workspace-audit.mjs +231 -0
  82. package/src/workspace-isolation.mjs +306 -0
  83. package/statusline/statusline.sh +14 -0
  84. package/statusline/worker-segment.sh +35 -0
  85. package/worker.cordis.yml +77 -0
@@ -0,0 +1,98 @@
1
+ // Thin DSH plugin entry wrapper for v0.3 runtime compatibility discovery.
2
+ //
3
+ // The legacy /ping endpoint stays reachability-only inside index.mjs. This
4
+ // wrapper adds a separate /runtime endpoint carrying the explicit Hub/MCP
5
+ // compatibility contract, then delegates all existing Hub behavior unchanged.
6
+ // It also owns the v0.3 adaptive-routing observer so the large legacy Hub body
7
+ // stays untouched: only jobs that explicitly opted into adaptive routing feed
8
+ // bounded process-local health for later selections.
9
+
10
+ import { apply as applyHub, inject, name, WorkerRegistry } from './index.mjs';
11
+ import { getHubRuntimeIdentity } from '../runtime-identity.mjs';
12
+ import { getProcessAdaptiveHealthStore } from '../adaptive-routing.mjs';
13
+
14
+ const RUNTIME_PATH = '/_dsh/dsh-crew/runtime';
15
+ const ADAPTIVE_OBSERVER_INSTALLED = Symbol.for('@ran-sh/dsh-crew/adaptive-observer-installed');
16
+ const ADAPTIVE_JOB_OBSERVED = Symbol.for('@ran-sh/dsh-crew/adaptive-job-observed');
17
+
18
+ export { inject, name };
19
+
20
+ function sendJson(res, status, value) {
21
+ const body = JSON.stringify(value);
22
+ res.writeHead(status, {
23
+ 'content-type': 'application/json; charset=utf-8',
24
+ 'content-length': Buffer.byteLength(body),
25
+ 'cache-control': 'no-store',
26
+ 'x-content-type-options': 'nosniff',
27
+ 'cross-origin-resource-policy': 'same-origin',
28
+ });
29
+ res.end(body);
30
+ }
31
+
32
+ export function registerRuntimeEndpoint(ctx) {
33
+ return ctx.inject(['webServer'], (webCtx) => webCtx.webServer.register({
34
+ kind: 'exact',
35
+ path: RUNTIME_PATH,
36
+ handler: (_req, res) => sendJson(res, 200, { ok: true, ...getHubRuntimeIdentity() }),
37
+ }));
38
+ }
39
+
40
+ /**
41
+ * Record only an opt-in adaptive Hub attempt. The store accepts bounded
42
+ * provider/model identifiers plus outcome/latency; arbitrary job errors,
43
+ * credentials, quota and provider payloads never cross this boundary.
44
+ */
45
+ export function recordAdaptiveJobOutcome(job, store = getProcessAdaptiveHealthStore()) {
46
+ if (job?.selection_trace?.adaptive?.enabled !== true) return false;
47
+ const started = Date.parse(job.startedAt ?? '');
48
+ const ended = Date.parse(job.endedAt ?? '');
49
+ const latencyMs = Number.isFinite(started) && Number.isFinite(ended)
50
+ ? Math.max(0, ended - started)
51
+ : undefined;
52
+ return store.record(
53
+ { provider: job.provider, model: job.model },
54
+ {
55
+ role: job.role,
56
+ status: job.status,
57
+ stopReason: job.stopReason,
58
+ latencyMs,
59
+ },
60
+ );
61
+ }
62
+
63
+ /**
64
+ * Wrap WorkerRegistry.spawn once per process. Selection itself still lives in
65
+ * the existing Hub implementation; rankAdaptiveCandidates reads the same
66
+ * process-local store through adaptive-routing.mjs. Replacing job.promise with
67
+ * a chained promise preserves all legacy completion/waiter behavior and runs
68
+ * this observer only after the Hub's own finalizer populated endedAt/status.
69
+ */
70
+ export function installAdaptiveHealthObserver() {
71
+ if (WorkerRegistry.prototype[ADAPTIVE_OBSERVER_INSTALLED] === true) return false;
72
+ const originalSpawn = WorkerRegistry.prototype.spawn;
73
+ Object.defineProperty(WorkerRegistry.prototype, ADAPTIVE_OBSERVER_INSTALLED, {
74
+ value: true,
75
+ enumerable: false,
76
+ configurable: false,
77
+ });
78
+ WorkerRegistry.prototype.spawn = async function observedAdaptiveSpawn(...args) {
79
+ const job = await originalSpawn.apply(this, args);
80
+ if (!job || job[ADAPTIVE_JOB_OBSERVED] === true || typeof job.promise?.finally !== 'function') return job;
81
+ Object.defineProperty(job, ADAPTIVE_JOB_OBSERVED, {
82
+ value: true,
83
+ enumerable: false,
84
+ configurable: false,
85
+ });
86
+ job.promise = job.promise.finally(() => {
87
+ recordAdaptiveJobOutcome(job);
88
+ });
89
+ return job;
90
+ };
91
+ return true;
92
+ }
93
+
94
+ export async function apply(ctx) {
95
+ registerRuntimeEndpoint(ctx);
96
+ installAdaptiveHealthObserver();
97
+ return applyHub(ctx);
98
+ }