@kirkchinese/harness-forge 0.0.0-stage → 0.5.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.
- package/LICENSE +21 -0
- package/README.md +46 -2
- package/assets/icon.svg +12 -0
- package/cordis.patch.yml +28 -0
- package/docs/DETAIL.zh.md +47 -0
- package/lib/agents/presets.d.ts +98 -0
- package/lib/agents/presets.js +292 -0
- package/lib/agents/profiles.d.ts +58 -0
- package/lib/agents/profiles.js +279 -0
- package/lib/agents/row.d.ts +17 -0
- package/lib/agents/row.js +148 -0
- package/lib/client/paths.d.ts +12 -0
- package/lib/client/paths.js +68 -0
- package/lib/client/styles.d.ts +8 -0
- package/lib/client/styles.js +89 -0
- package/lib/client/typert.d.ts +25 -0
- package/lib/client/typert.js +158 -0
- package/lib/client.js +23823 -0
- package/lib/commands/definition.d.ts +40 -0
- package/lib/commands/definition.js +113 -0
- package/lib/commands/output-styles.d.ts +42 -0
- package/lib/commands/output-styles.js +152 -0
- package/lib/commands/row.d.ts +9 -0
- package/lib/commands/row.js +157 -0
- package/lib/context/instructions.d.ts +32 -0
- package/lib/context/instructions.js +88 -0
- package/lib/context/row.d.ts +16 -0
- package/lib/context/row.js +17 -0
- package/lib/dsh/commands.d.ts +30 -0
- package/lib/dsh/commands.js +61 -0
- package/lib/dsh/host.d.ts +110 -0
- package/lib/dsh/host.js +217 -0
- package/lib/dsh/model-route.d.ts +21 -0
- package/lib/dsh/model-route.js +37 -0
- package/lib/dsh/session-records.d.ts +78 -0
- package/lib/dsh/session-records.js +36 -0
- package/lib/dsh/subagents.d.ts +46 -0
- package/lib/dsh/subagents.js +14 -0
- package/lib/forge/contract.d.ts +271 -0
- package/lib/forge/contract.js +45 -0
- package/lib/forge/follow.d.ts +30 -0
- package/lib/forge/follow.js +73 -0
- package/lib/forge/ledger.d.ts +206 -0
- package/lib/forge/ledger.js +1005 -0
- package/lib/forge/live-mounts.d.ts +45 -0
- package/lib/forge/live-mounts.js +78 -0
- package/lib/forge/npm.d.ts +31 -0
- package/lib/forge/npm.js +60 -0
- package/lib/forge/projects.d.ts +97 -0
- package/lib/forge/projects.js +343 -0
- package/lib/forge/receipts.d.ts +5 -0
- package/lib/forge/receipts.js +31 -0
- package/lib/forge/remote/archive.d.ts +65 -0
- package/lib/forge/remote/archive.js +565 -0
- package/lib/forge/remote/code-parts.d.ts +18 -0
- package/lib/forge/remote/code-parts.js +76 -0
- package/lib/forge/remote/fetch.d.ts +265 -0
- package/lib/forge/remote/fetch.js +1133 -0
- package/lib/forge/remote/service.d.ts +256 -0
- package/lib/forge/remote/service.js +868 -0
- package/lib/forge/row.d.ts +32 -0
- package/lib/forge/row.js +59 -0
- package/lib/forge/service.d.ts +115 -0
- package/lib/forge/service.js +290 -0
- package/lib/forge/settings.d.ts +43 -0
- package/lib/forge/settings.js +122 -0
- package/lib/forge/state.d.ts +129 -0
- package/lib/forge/state.js +266 -0
- package/lib/forge/trust.d.ts +48 -0
- package/lib/forge/trust.js +107 -0
- package/lib/forge/turns.d.ts +13 -0
- package/lib/forge/turns.js +56 -0
- package/lib/hooks/broker/engine.d.ts +112 -0
- package/lib/hooks/broker/engine.js +722 -0
- package/lib/hooks/broker/helpers.d.ts +10 -0
- package/lib/hooks/broker/helpers.js +22 -0
- package/lib/hooks/broker/lifecycle.d.ts +65 -0
- package/lib/hooks/broker/lifecycle.js +342 -0
- package/lib/hooks/broker/session-events.d.ts +27 -0
- package/lib/hooks/broker/session-events.js +205 -0
- package/lib/hooks/broker/tools.d.ts +52 -0
- package/lib/hooks/broker/tools.js +424 -0
- package/lib/hooks/broker/types.d.ts +264 -0
- package/lib/hooks/broker/types.js +1 -0
- package/lib/hooks/broker.d.ts +80 -0
- package/lib/hooks/broker.js +95 -0
- package/lib/hooks/codex-user.d.ts +5 -0
- package/lib/hooks/codex-user.js +109 -0
- package/lib/hooks/condition.d.ts +87 -0
- package/lib/hooks/condition.js +602 -0
- package/lib/hooks/config.d.ts +85 -0
- package/lib/hooks/config.js +154 -0
- package/lib/hooks/glob.d.ts +41 -0
- package/lib/hooks/glob.js +114 -0
- package/lib/hooks/matcher.d.ts +20 -0
- package/lib/hooks/matcher.js +39 -0
- package/lib/hooks/notice.d.ts +17 -0
- package/lib/hooks/notice.js +39 -0
- package/lib/hooks/output.d.ts +56 -0
- package/lib/hooks/output.js +214 -0
- package/lib/hooks/permissions.d.ts +19 -0
- package/lib/hooks/permissions.js +202 -0
- package/lib/hooks/powershell-aliases.d.ts +19 -0
- package/lib/hooks/powershell-aliases.js +58 -0
- package/lib/hooks/process.d.ts +64 -0
- package/lib/hooks/process.js +289 -0
- package/lib/hooks/row.d.ts +17 -0
- package/lib/hooks/row.js +96 -0
- package/lib/hooks/runner.d.ts +98 -0
- package/lib/hooks/runner.js +322 -0
- package/lib/hooks/shell-commands.d.ts +28 -0
- package/lib/hooks/shell-commands.js +241 -0
- package/lib/hooks/shell.d.ts +44 -0
- package/lib/hooks/shell.js +129 -0
- package/lib/hooks/transcript.d.ts +28 -0
- package/lib/hooks/transcript.js +141 -0
- package/lib/hooks/vocabulary.d.ts +57 -0
- package/lib/hooks/vocabulary.js +366 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.js +287 -0
- package/lib/mcp/auth.d.ts +35 -0
- package/lib/mcp/auth.js +178 -0
- package/lib/mcp/catalog.d.ts +39 -0
- package/lib/mcp/catalog.js +69 -0
- package/lib/mcp/mount.d.ts +113 -0
- package/lib/mcp/mount.js +317 -0
- package/lib/mcp/policy.d.ts +42 -0
- package/lib/mcp/policy.js +43 -0
- package/lib/mcp/remote.d.ts +45 -0
- package/lib/mcp/remote.js +133 -0
- package/lib/mcp/row.d.ts +9 -0
- package/lib/mcp/row.js +225 -0
- package/lib/mods/bundler.d.ts +38 -0
- package/lib/mods/bundler.js +157 -0
- package/lib/mods/chain.d.ts +103 -0
- package/lib/mods/chain.js +436 -0
- package/lib/mods/claude.d.ts +27 -0
- package/lib/mods/claude.js +56 -0
- package/lib/mods/engine.d.ts +160 -0
- package/lib/mods/engine.js +701 -0
- package/lib/mods/expect.d.ts +8 -0
- package/lib/mods/expect.js +248 -0
- package/lib/mods/host.d.ts +105 -0
- package/lib/mods/host.js +462 -0
- package/lib/mods/loader.d.ts +53 -0
- package/lib/mods/loader.js +231 -0
- package/lib/mods/ops.d.ts +13 -0
- package/lib/mods/ops.js +117 -0
- package/lib/mods/row.d.ts +9 -0
- package/lib/mods/row.js +77 -0
- package/lib/mods/runtime.d.ts +60 -0
- package/lib/mods/runtime.js +133 -0
- package/lib/mods/service/commands.d.ts +17 -0
- package/lib/mods/service/commands.js +121 -0
- package/lib/mods/service/drawings.d.ts +36 -0
- package/lib/mods/service/drawings.js +64 -0
- package/lib/mods/service/sessions.d.ts +63 -0
- package/lib/mods/service/sessions.js +345 -0
- package/lib/mods/service/tools.d.ts +32 -0
- package/lib/mods/service/tools.js +253 -0
- package/lib/mods/service/turns.d.ts +33 -0
- package/lib/mods/service/turns.js +136 -0
- package/lib/mods/service/types.d.ts +151 -0
- package/lib/mods/service/types.js +1 -0
- package/lib/mods/service.d.ts +72 -0
- package/lib/mods/service.js +104 -0
- package/lib/mods/surfaces.d.ts +93 -0
- package/lib/mods/surfaces.js +309 -0
- package/lib/mods/values.d.ts +30 -0
- package/lib/mods/values.js +95 -0
- package/lib/opencode/bun.d.ts +40 -0
- package/lib/opencode/bun.js +168 -0
- package/lib/opencode/convert.d.ts +53 -0
- package/lib/opencode/convert.js +255 -0
- package/lib/opencode/row.d.ts +22 -0
- package/lib/opencode/row.js +104 -0
- package/lib/opencode/runtime/core.d.ts +74 -0
- package/lib/opencode/runtime/core.js +249 -0
- package/lib/opencode/runtime/events.d.ts +80 -0
- package/lib/opencode/runtime/events.js +281 -0
- package/lib/opencode/runtime/mount.d.ts +27 -0
- package/lib/opencode/runtime/mount.js +283 -0
- package/lib/opencode/runtime/server.d.ts +27 -0
- package/lib/opencode/runtime/server.js +354 -0
- package/lib/opencode/runtime/types.d.ts +109 -0
- package/lib/opencode/runtime/types.js +1 -0
- package/lib/opencode/runtime.d.ts +55 -0
- package/lib/opencode/runtime.js +79 -0
- package/lib/porting/adapter-paths.d.ts +13 -0
- package/lib/porting/adapter-paths.js +120 -0
- package/lib/porting/port-gap.d.ts +36 -0
- package/lib/porting/port-gap.js +158 -0
- package/lib/porting/port-sessions.d.ts +41 -0
- package/lib/porting/port-sessions.js +98 -0
- package/lib/porting/prompt.d.ts +23 -0
- package/lib/porting/prompt.js +51 -0
- package/lib/porting/row.d.ts +16 -0
- package/lib/porting/row.js +27 -0
- package/lib/porting/verify-port.d.ts +46 -0
- package/lib/porting/verify-port.js +82 -0
- package/lib/presets/fs-search.d.ts +25 -0
- package/lib/presets/fs-search.js +17 -0
- package/lib/presets/tool-filter.d.ts +35 -0
- package/lib/presets/tool-filter.js +91 -0
- package/lib/sessions/chat-import.d.ts +48 -0
- package/lib/sessions/chat-import.js +44 -0
- package/lib/sessions/claude.d.ts +35 -0
- package/lib/sessions/claude.js +104 -0
- package/lib/sessions/codex-discover.d.ts +34 -0
- package/lib/sessions/codex-discover.js +205 -0
- package/lib/sessions/codex-meta.d.ts +63 -0
- package/lib/sessions/codex-meta.js +148 -0
- package/lib/sessions/codex-text.d.ts +9 -0
- package/lib/sessions/codex-text.js +44 -0
- package/lib/sessions/codex.d.ts +42 -0
- package/lib/sessions/codex.js +270 -0
- package/lib/sessions/opencode.d.ts +38 -0
- package/lib/sessions/opencode.js +339 -0
- package/lib/sessions/persist.d.ts +162 -0
- package/lib/sessions/persist.js +377 -0
- package/lib/sessions/row.d.ts +15 -0
- package/lib/sessions/row.js +101 -0
- package/lib/sessions/turns.d.ts +31 -0
- package/lib/sessions/turns.js +63 -0
- package/lib/sessions/zstd.d.ts +15 -0
- package/lib/sessions/zstd.js +152 -0
- package/lib/shared/invocation.d.ts +169 -0
- package/lib/shared/invocation.js +325 -0
- package/lib/shared/render.d.ts +101 -0
- package/lib/shared/render.js +1353 -0
- package/lib/shared/util.d.ts +21 -0
- package/lib/shared/util.js +32 -0
- package/lib/skills/bundled.d.ts +3 -0
- package/lib/skills/bundled.js +42 -0
- package/lib/skills/provider.d.ts +74 -0
- package/lib/skills/provider.js +346 -0
- package/lib/skills/row.d.ts +22 -0
- package/lib/skills/row.js +204 -0
- package/lib/workbench/adapter-coverage.d.ts +65 -0
- package/lib/workbench/adapter-coverage.js +141 -0
- package/lib/workbench/model-tools.d.ts +10 -0
- package/lib/workbench/model-tools.js +122 -0
- package/lib/workbench/overview.d.ts +153 -0
- package/lib/workbench/overview.js +246 -0
- package/lib/workbench/remote.d.ts +161 -0
- package/lib/workbench/remote.js +561 -0
- package/lib/workbench/row.d.ts +15 -0
- package/lib/workbench/row.js +16 -0
- package/lib/workbench/settings.d.ts +19 -0
- package/lib/workbench/settings.js +60 -0
- package/lib/workbench/workbench.d.ts +130 -0
- package/lib/workbench/workbench.js +361 -0
- package/locale/agents/en.json +6 -0
- package/locale/agents/zh.json +6 -0
- package/locale/commands/en.json +6 -0
- package/locale/commands/zh.json +6 -0
- package/locale/context/en.json +6 -0
- package/locale/context/zh.json +6 -0
- package/locale/en.json +6 -0
- package/locale/hooks/en.json +6 -0
- package/locale/hooks/zh.json +6 -0
- package/locale/mcp/en.json +6 -0
- package/locale/mcp/zh.json +6 -0
- package/locale/mods/en.json +6 -0
- package/locale/mods/zh.json +6 -0
- package/locale/opencode/en.json +6 -0
- package/locale/opencode/zh.json +6 -0
- package/locale/porter/en.json +6 -0
- package/locale/porter/zh.json +6 -0
- package/locale/sessions/en.json +6 -0
- package/locale/sessions/zh.json +6 -0
- package/locale/skills/en.json +6 -0
- package/locale/skills/zh.json +6 -0
- package/locale/workbench/en.json +6 -0
- package/locale/workbench/zh.json +6 -0
- package/locale/zh.json +7 -0
- package/package.json +247 -3
- package/runtime/opencode-host.mjs +270 -0
- package/skills/harness-forge/SKILL.md +47 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import { type ContextFormed } from '@deepseek-ai/dsh-llm';
|
|
3
|
+
import { type HookNotice } from '../notice.js';
|
|
4
|
+
import { TranscriptMirror } from '../transcript.js';
|
|
5
|
+
import type { AgentLike, HookBrokerHost, HookSource, Occurrence, Ran, SessionLike, SessionState } from './types.js';
|
|
6
|
+
declare module '@deepseek-ai/dsh-llm' {
|
|
7
|
+
interface MessageSourceMap {
|
|
8
|
+
'harness-forge': {
|
|
9
|
+
kind: 'harness-forge';
|
|
10
|
+
readonly event?: string;
|
|
11
|
+
} & ContextFormed;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare const CONTEXT_SOURCE: {
|
|
15
|
+
readonly kind: "harness-forge";
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The broker's shared engine: the registered sources, per-session state, the
|
|
19
|
+
* handler runs and how their outcomes combine, notices, environment files and
|
|
20
|
+
* the host facts every part of the broker reads.
|
|
21
|
+
*/
|
|
22
|
+
export declare class HookEngine {
|
|
23
|
+
readonly ctx: Context;
|
|
24
|
+
readonly host: HookBrokerHost;
|
|
25
|
+
readonly sources: Map<string, HookSource>;
|
|
26
|
+
readonly sessions: Map<string, SessionState>;
|
|
27
|
+
private readonly runner;
|
|
28
|
+
readonly transcripts: TranscriptMirror;
|
|
29
|
+
readonly detached: Set<Promise<unknown>>;
|
|
30
|
+
readonly ending: Set<Promise<unknown>>;
|
|
31
|
+
readonly lifetime: AbortController;
|
|
32
|
+
private readonly onceDone;
|
|
33
|
+
readonly notifyTimers: Map<string, NodeJS.Timeout>;
|
|
34
|
+
readonly idleTimers: Map<string, NodeJS.Timeout>;
|
|
35
|
+
constructor(ctx: Context, host: HookBrokerHost);
|
|
36
|
+
/** Register one source; the returned disposer removes it. */
|
|
37
|
+
add(source: HookSource): () => void;
|
|
38
|
+
has(event: string): boolean;
|
|
39
|
+
hasAgentStop(agent: AgentLike): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Run every matching handler of one occurrence in parallel and decode the
|
|
42
|
+
* synchronous ones. Background handlers deliver their output later.
|
|
43
|
+
*/
|
|
44
|
+
run(occurrence: Occurrence & {
|
|
45
|
+
response?: {
|
|
46
|
+
value: unknown;
|
|
47
|
+
text: string;
|
|
48
|
+
};
|
|
49
|
+
}, extra?: {
|
|
50
|
+
envFile?: string;
|
|
51
|
+
}): Promise<Ran[]>;
|
|
52
|
+
private runHandler;
|
|
53
|
+
/** Whether a failed run of this handler blocks the action. */
|
|
54
|
+
private blocksOnFailure;
|
|
55
|
+
/** Whether a decoded output allows the action outright. */
|
|
56
|
+
private allows;
|
|
57
|
+
/** Deliver a background run: context and system message on the next model request; asyncRewake wakes the agent on exit 2. */
|
|
58
|
+
private deliverAsync;
|
|
59
|
+
/** The stdin payload / POST body of one handler. */
|
|
60
|
+
private payload;
|
|
61
|
+
private timeoutFor;
|
|
62
|
+
/** The SessionEnd budget: 1.5 s, raised by settings hooks' own timeouts up to 60 s, or the env override. */
|
|
63
|
+
sessionEndBudget(): number;
|
|
64
|
+
sessionEndDefault(): number;
|
|
65
|
+
/** The first `continue: false`, as its stop reason. */
|
|
66
|
+
stopOf(results: readonly Ran[]): string | undefined;
|
|
67
|
+
/** A top-level `decision: "block"` or a blocking exit, as the block reason. */
|
|
68
|
+
blockOf(event: string, results: readonly Ran[]): string | undefined;
|
|
69
|
+
/** A prompt/agent `ok: false`. */
|
|
70
|
+
modelBlock(results: readonly Ran[], continueOnBlock: boolean): string | undefined;
|
|
71
|
+
/** Every context string the runs add for the model. */
|
|
72
|
+
contexts(event: string, results: readonly Ran[]): string[];
|
|
73
|
+
/** Apply the 10,000-character cap (Codex: `additionalContextLimit` tokens): spill to a file with a preview. */
|
|
74
|
+
private bound;
|
|
75
|
+
/** Notices for hook errors, system messages and terminal notifications of every run. */
|
|
76
|
+
noticeAll(agent: AgentLike, event: string, subject: string | undefined, results: readonly Ran[]): void;
|
|
77
|
+
notice(agent: AgentLike | undefined, notice: HookNotice): void;
|
|
78
|
+
/** `continue: false` or an ending block: stop the agent and tell the user why. */
|
|
79
|
+
halt(agent: AgentLike, event: string, reason: string, results: readonly Ran[]): void;
|
|
80
|
+
/** Context for the model, as a system reminder naming the hook event. */
|
|
81
|
+
reminder(_agent: AgentLike | undefined, event: string, text: string): string;
|
|
82
|
+
contextMessage(agent: AgentLike | undefined, event: string, text: string): unknown;
|
|
83
|
+
/** The env file a session's SessionStart (`session`) or CwdChanged/FileChanged (`cwd`) hooks append to. */
|
|
84
|
+
envFile(session: SessionLike, scope: 'session' | 'cwd'): string;
|
|
85
|
+
clearEnv(session: SessionLike, scope: 'cwd'): void;
|
|
86
|
+
/**
|
|
87
|
+
* The prefix that applies imported settings `env`, then the session's env
|
|
88
|
+
* files, to one shell tool command.
|
|
89
|
+
*/
|
|
90
|
+
shellEnvPrefix(agent: AgentLike, dshName: string, extra?: Readonly<Record<string, string>>): string | undefined;
|
|
91
|
+
state(session: SessionLike): SessionState & {
|
|
92
|
+
cwd?: string;
|
|
93
|
+
lastSummary?: string;
|
|
94
|
+
};
|
|
95
|
+
private sourceApplies;
|
|
96
|
+
toolContext(agent?: AgentLike, cwd?: string): {
|
|
97
|
+
cwd?: string;
|
|
98
|
+
agentName: (id: string) => string | undefined;
|
|
99
|
+
presetOf: (name: string) => string | undefined;
|
|
100
|
+
};
|
|
101
|
+
agentOf(sessionId: string): AgentLike | undefined;
|
|
102
|
+
directory(agent: AgentLike, signal: AbortSignal): Promise<string>;
|
|
103
|
+
committedDirectory(agent: AgentLike): string | undefined;
|
|
104
|
+
private lastTurn;
|
|
105
|
+
presetOf(agent: AgentLike): string | undefined;
|
|
106
|
+
/** Claude's `agent_type`: the imported agent's own name, else `general-purpose`. */
|
|
107
|
+
agentTypeOf(child: AgentLike): string;
|
|
108
|
+
/** The foreign permission mode for the session's DSH permission preset and plan mode. */
|
|
109
|
+
private permissionMode;
|
|
110
|
+
rename(agent: AgentLike, title: string): void;
|
|
111
|
+
track(promise: Promise<unknown>): void;
|
|
112
|
+
}
|