@kasenri/dsh-orbit 0.5.1

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.
package/lib/tool.js ADDED
@@ -0,0 +1,82 @@
1
+ import { defineTool } from '@deepseek-ai/dsh-tools';
2
+ export const ORBIT_TOOL_NAME = 'orbit_controller';
3
+ /** Legacy tool name kept as a backward-compatible alias. */
4
+ export const LEGACY_CX_TOOL_NAME = 'cx_controller';
5
+ const TOOL_DESCRIPTION = 'Drive Orbit engineering autonomy for the current project. Orbit runs a deterministic Supervisor ' +
6
+ '(Commander -> Executor -> Smart Watchdog) over a durable .cx/state.json. Use action "run" with a ' +
7
+ 'goal to start or continue, "resume" to continue a persisted run, "status" to inspect, "stop" to ' +
8
+ 'close the run, and "doctor" to check the environment. Only Orbit writes .cx durable state.';
9
+ const LEGACY_TOOL_DESCRIPTION = `Legacy compatibility alias. Prefer ${ORBIT_TOOL_NAME}. ${TOOL_DESCRIPTION}`;
10
+ function summarize(result) {
11
+ const lines = [`orbit ${result.action}: ok=${result.ok} phase=${result.phase ?? '-'} status=${result.status ?? '-'}`];
12
+ if (result.run_id)
13
+ lines.push(`run_id: ${result.run_id}`);
14
+ if (result.message)
15
+ lines.push(`message: ${result.message}`);
16
+ const data = result.data;
17
+ if (data) {
18
+ if (data['loop'])
19
+ lines.push(`loop: ${JSON.stringify(data['loop'])}`);
20
+ if (data['current_step'])
21
+ lines.push(`current_step: ${JSON.stringify(data['current_step'])}`);
22
+ if (data['last_error'])
23
+ lines.push(`last_error: ${JSON.stringify(data['last_error'])}`);
24
+ if (Array.isArray(data['plan']))
25
+ lines.push(`plan: ${JSON.stringify(data['plan'])}`);
26
+ }
27
+ return lines.join('\n');
28
+ }
29
+ /**
30
+ * One tool implementation shared by the canonical `orbit_controller` tool and
31
+ * the legacy `cx_controller` alias. Both names call the same OrbitService.
32
+ */
33
+ export function createOrbitTool(ctx, options = {}) {
34
+ const legacy = options.legacy === true;
35
+ return defineTool({
36
+ name: legacy ? LEGACY_CX_TOOL_NAME : ORBIT_TOOL_NAME,
37
+ description: legacy ? LEGACY_TOOL_DESCRIPTION : TOOL_DESCRIPTION,
38
+ parameters: {
39
+ action: { type: 'string', required: true, enum: ['run', 'start', 'resume', 'stop', 'status', 'doctor'] },
40
+ goal: { type: 'string', description: 'The engineering goal (required for run/start).' },
41
+ preset: { type: 'string', description: 'Run preset id.' },
42
+ approved_loop_count: { type: 'integer', description: 'Explicit loop budget (positive, <= 10).' },
43
+ run_id: { type: 'string', description: 'Target run id for resume/stop.' },
44
+ user_hard_constraints: { type: 'array', items: { type: 'string' } },
45
+ github_allowed: { type: 'boolean', description: 'Allow GitHub remote writes for this run.' },
46
+ },
47
+ output: {
48
+ schema: { type: 'json' },
49
+ render: (_args, value) => {
50
+ const result = value;
51
+ return [{ type: 'text', text: summarize(result) }];
52
+ },
53
+ },
54
+ async execute(args, exec) {
55
+ // The service is provided by this plugin's own fiber; reading it through
56
+ // `agent.ctx` would require an inject declaration on the agent scope.
57
+ const scope = ctx;
58
+ const service = scope.orbit ?? scope.cx;
59
+ if (!service)
60
+ throw new Error('orbit service is unavailable; dsh-orbit is not loaded.');
61
+ const agent = exec.agent;
62
+ const cwd = agent?.session?.header?.cwd ?? process.cwd();
63
+ const input = {
64
+ ...(args.goal !== undefined ? { goal: args.goal } : {}),
65
+ ...(args.preset !== undefined ? { preset: args.preset } : {}),
66
+ ...(args.approved_loop_count !== undefined ? { approved_loop_count: args.approved_loop_count } : {}),
67
+ ...(args.run_id !== undefined ? { run_id: args.run_id } : {}),
68
+ ...(args.user_hard_constraints !== undefined ? { user_hard_constraints: args.user_hard_constraints } : {}),
69
+ ...(args.github_allowed !== undefined ? { github_allowed: args.github_allowed } : {}),
70
+ };
71
+ if (args.action === 'status')
72
+ return (await service.status(cwd));
73
+ if (args.action === 'stop')
74
+ return service.stop(args.run_id, cwd);
75
+ if (args.action === 'doctor')
76
+ return (await service.doctor(cwd));
77
+ if (args.action === 'resume')
78
+ return (await service.resume(input, cwd, exec.signal));
79
+ return (await service.run(input, cwd, exec.signal));
80
+ },
81
+ });
82
+ }
package/lib/types.js ADDED
@@ -0,0 +1,19 @@
1
+ /** Durable Orbit state and decision vocabulary. */
2
+ export const ORBIT_SCHEMA_VERSION = 2;
3
+ export const COMMANDER_SOFT_DEADLINE_MS = 6 * 60_000;
4
+ export const COMMANDER_EXTENSION_MS = 4 * 60_000;
5
+ export const COMMANDER_HARD_CEILING_MS = 14 * 60_000;
6
+ export const EXECUTOR_TIMEOUT_MS = 8 * 60_000;
7
+ export const WATCHDOG_TIMEOUT_MS = 2 * 60_000;
8
+ export const GUARD_ESCALATION_THRESHOLD = 3;
9
+ export const GUARD_RECOVERY_CAP = 4;
10
+ export const MAX_CORRECTION_DEPTH = 2;
11
+ export const MAX_WATCHDOG_CALLS_PER_STEP = 2;
12
+ export const MAX_EXECUTOR_INTERRUPT_RETRIES = 2;
13
+ export const MAX_PLAN_STEPS = 5;
14
+ export const MIN_PLAN_STEPS = 1;
15
+ export const GUARD_FIRST_INSTRUCTION = 'Use a safer method and continue the current task. Do not retry the same blocked operation unchanged.';
16
+ export const GUARD_REPEAT_INSTRUCTION = 'The same blocked operation was attempted again. Stop repeating it and choose a different safe approach.';
17
+ export const GUARD_RETRY_INSTRUCTION = 'The previous approach repeatedly hit Orbit safety guards. Use a different safe approach. Do not retry the blocked operation.';
18
+ export const GUARD_NEEDS_USER_INSTRUCTION = 'This restricted action appears necessary for the user goal. Orbit has paused for user guidance.';
19
+ export const DEFAULT_CAPABILITIES = ['browser', 'web-api-recon'];
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@kasenri/dsh-orbit",
3
+ "version": "0.5.1",
4
+ "type": "module",
5
+ "description": "Deterministic engineering orchestration for DeepSeek Harness with Commander, Executor, Smart Watchdog, bounded recovery and durable execution state.",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/KasenRi/dsh-orbit-browser-plugins.git",
10
+ "directory": "packages/orbit"
11
+ },
12
+ "homepage": "https://github.com/KasenRi/dsh-orbit-browser-plugins/tree/main/packages/orbit#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/KasenRi/dsh-orbit-browser-plugins/issues"
15
+ },
16
+ "keywords": [
17
+ "dsh-plugin",
18
+ "deepseek-harness",
19
+ "orbit",
20
+ "engineering-orchestration",
21
+ "agent-orchestration",
22
+ "autonomous-engineering",
23
+ "bounded-loop",
24
+ "workflow"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "main": "lib/index.js",
30
+ "exports": {
31
+ ".": "./lib/index.js",
32
+ "./client": "./lib/client.js",
33
+ "./cordis.patch.yml": "./cordis.patch.yml",
34
+ "./package.json": "./package.json"
35
+ },
36
+ "files": [
37
+ "lib",
38
+ "cordis.patch.yml",
39
+ "README.md",
40
+ "LICENSE"
41
+ ],
42
+ "engines": {
43
+ "node": ">=22.19.0"
44
+ },
45
+ "dsh": {
46
+ "bundle": {
47
+ "patch": "./cordis.patch.yml"
48
+ },
49
+ "client": {
50
+ "platform": "web",
51
+ "inject": [
52
+ "@deepseek-ai/dsh-api-remotes",
53
+ "@deepseek-ai/dsh-client-locale",
54
+ "@deepseek-ai/dsh-client-ui-model-selection"
55
+ ]
56
+ }
57
+ },
58
+ "peerDependencies": {
59
+ "@deepseek-ai/cordis": "^4.0.2",
60
+ "@deepseek-ai/dsh-agent": "^0.1.5-rc.2",
61
+ "@deepseek-ai/dsh-commands": "^0.1.5-rc.2",
62
+ "@deepseek-ai/dsh-llm": "^0.1.5-rc.2",
63
+ "@deepseek-ai/dsh-subagent": "^0.1.5-rc.2",
64
+ "@deepseek-ai/dsh-tools": "^0.1.5-rc.2"
65
+ },
66
+ "peerDependenciesMeta": {
67
+ "@deepseek-ai/dsh-commands": {
68
+ "optional": true
69
+ },
70
+ "@deepseek-ai/dsh-llm": {
71
+ "optional": true
72
+ }
73
+ }
74
+ }