@code-yeongyu/senpi 2026.8.10 → 2026.8.11-2
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/CHANGELOG.md +54 -0
- package/dist/brand-dir-migration.d.ts +28 -0
- package/dist/brand-dir-migration.d.ts.map +1 -0
- package/dist/brand-dir-migration.js +77 -0
- package/dist/brand-dir-migration.js.map +1 -0
- package/dist/cli/grok-neo-gate.d.ts +0 -8
- package/dist/cli/grok-neo-gate.d.ts.map +1 -1
- package/dist/cli/grok-neo-gate.js +4 -2
- package/dist/cli/grok-neo-gate.js.map +1 -1
- package/dist/cli-main.js +3 -0
- package/dist/cli-main.js.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +27 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +41 -9
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/brand.d.ts +79 -0
- package/dist/core/brand.d.ts.map +1 -0
- package/dist/core/brand.js +141 -0
- package/dist/core/brand.js.map +1 -0
- package/dist/core/dynamic-prompt/identity.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/identity.js +2 -1
- package/dist/core/dynamic-prompt/identity.js.map +1 -1
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +2 -1
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js +10 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.js +2 -1
- package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
- package/dist/core/extensions/builtin/config-reload/generated-shim-filter.d.ts.map +1 -1
- package/dist/core/extensions/builtin/config-reload/generated-shim-filter.js +4 -4
- package/dist/core/extensions/builtin/config-reload/generated-shim-filter.js.map +1 -1
- package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/index.js +5 -0
- package/dist/core/extensions/builtin/goal/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts +2 -2
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js +3 -3
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.js +6 -0
- package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/store.d.ts +3 -2
- package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/store.js +128 -101
- package/dist/core/extensions/builtin/goal/store.js.map +1 -1
- package/dist/core/extensions/builtin/help/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/help/index.js +3 -2
- package/dist/core/extensions/builtin/help/index.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js +6 -5
- package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +2 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -4
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +0 -7
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/generated-shim-banner.d.ts +15 -0
- package/dist/core/generated-shim-banner.d.ts.map +1 -0
- package/dist/core/generated-shim-banner.js +26 -0
- package/dist/core/generated-shim-banner.js.map +1 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +7 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +2 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -5
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/session-log.d.ts.map +1 -1
- package/dist/core/session-log.js +4 -2
- package/dist/core/session-log.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +3 -2
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/telemetry.d.ts.map +1 -1
- package/dist/core/telemetry.js +2 -1
- package/dist/core/telemetry.js.map +1 -1
- package/dist/core/timings.d.ts +0 -4
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +2 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/inspector-policy.d.ts.map +1 -1
- package/dist/inspector-policy.js +2 -1
- package/dist/inspector-policy.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -4
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -0
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -8
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +6 -7
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/cli-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/cli-tips.js +2 -1
- package/dist/modes/interactive/tips/catalog/cli-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/ethos-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/ethos-tips.js +4 -3
- package/dist/modes/interactive/tips/catalog/ethos-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/model-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/model-tips.js +2 -1
- package/dist/modes/interactive/tips/catalog/model-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/session-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/session-tips.js +2 -1
- package/dist/modes/interactive/tips/catalog/session-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/settings-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/settings-tips.js +3 -2
- package/dist/modes/interactive/tips/catalog/settings-tips.js.map +1 -1
- package/dist/modes/interactive/tips/catalog/workspace-tips.d.ts.map +1 -1
- package/dist/modes/interactive/tips/catalog/workspace-tips.js +4 -3
- package/dist/modes/interactive/tips/catalog/workspace-tips.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/nearest-parent-config.d.ts +6 -1
- package/dist/nearest-parent-config.d.ts.map +1 -1
- package/dist/nearest-parent-config.js +18 -2
- package/dist/nearest-parent-config.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +13 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/rpc-entry.js +2 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/self-update-bootstrap.d.ts.map +1 -1
- package/dist/self-update-bootstrap.js +6 -0
- package/dist/self-update-bootstrap.js.map +1 -1
- package/dist/senpi +2 -2
- package/dist/utils/pi-user-agent.d.ts +1 -1
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js +4 -3
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +2 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +3 -0
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +37 -6
- package/dist/utils/version-check.js.map +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +24 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/wire-identity.d.ts +14 -0
- package/node_modules/@earendil-works/pi-ai/dist/wire-identity.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/wire-identity.js +24 -0
- package/node_modules/@earendil-works/pi-ai/dist/wire-identity.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/package.json +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.js +11 -3
- package/node_modules/@earendil-works/pi-pty/dist/pipe-fallback.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +6 -6
- package/dist/core/omo-native-detect.d.ts +0 -3
- package/dist/core/omo-native-detect.d.ts.map +0 -1
- package/dist/core/omo-native-detect.js +0 -64
- package/dist/core/omo-native-detect.js.map +0 -1
- package/dist/core/omo-native-detect.test.d.ts +0 -2
- package/dist/core/omo-native-detect.test.d.ts.map +0 -1
- package/dist/core/omo-native-detect.test.js +0 -47
- package/dist/core/omo-native-detect.test.js.map +0 -1
- package/dist/modes/interactive/components/footer-omo-native-badge.test.d.ts +0 -2
- package/dist/modes/interactive/components/footer-omo-native-badge.test.d.ts.map +0 -1
- package/dist/modes/interactive/components/footer-omo-native-badge.test.js +0 -52
- package/dist/modes/interactive/components/footer-omo-native-badge.test.js.map +0 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand profile resolution.
|
|
3
|
+
*
|
|
4
|
+
* A distribution that repackages this engine (for example the `omo-ai` package) injects a
|
|
5
|
+
* single JSON environment variable describing how the product presents itself. The engine
|
|
6
|
+
* parses it once at startup and then REMOVES it from the environment, so nested processes
|
|
7
|
+
* spawned by tools inherit a clean environment and keep the engine's own identity.
|
|
8
|
+
*
|
|
9
|
+
* Absent or malformed input leaves every brand-derived value at its standalone default, so a
|
|
10
|
+
* plain install behaves exactly as it did before this module existed.
|
|
11
|
+
*/
|
|
12
|
+
/** Environment variable carrying the JSON brand profile. */
|
|
13
|
+
export declare const BRAND_ENV_VAR = "SENPI_BRAND";
|
|
14
|
+
/**
|
|
15
|
+
* Where a repackaging distribution publishes itself. Without this the engine keeps checking
|
|
16
|
+
* its own package, which would advertise an update the branded product cannot install.
|
|
17
|
+
*/
|
|
18
|
+
export interface BrandUpdateChannel {
|
|
19
|
+
/** Registry package that ships the branded product, e.g. `omo-ai`. */
|
|
20
|
+
readonly packageName: string;
|
|
21
|
+
/** Dist-tag the product publishes on, e.g. `beta`. */
|
|
22
|
+
readonly distTag: string;
|
|
23
|
+
/** Command shown to the user, e.g. `npm i -g omo-ai@beta`. */
|
|
24
|
+
readonly command: string;
|
|
25
|
+
/** Release notes URL; `{version}` is replaced with the available version. */
|
|
26
|
+
readonly changelogUrl?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface BrandProfile {
|
|
29
|
+
/** Product name shown to users and to the model. */
|
|
30
|
+
readonly name: string;
|
|
31
|
+
/** Version shown in the header, terminal titles and `--version`. */
|
|
32
|
+
readonly displayVersion?: string;
|
|
33
|
+
/** Config directory name, e.g. `.omo`. */
|
|
34
|
+
readonly configDir: string;
|
|
35
|
+
/** When true the agent state lives directly under the config directory, with no `agent` segment. */
|
|
36
|
+
readonly flatLayout: boolean;
|
|
37
|
+
/** Prefix for the product's environment variables, e.g. `OMO`. */
|
|
38
|
+
readonly envPrefix: string;
|
|
39
|
+
/** Product token used in the outgoing user agent. */
|
|
40
|
+
readonly userAgent: string;
|
|
41
|
+
/** Product token used as the provider-side originator, when the distribution overrides it. */
|
|
42
|
+
readonly originator?: string;
|
|
43
|
+
/** Update channel of the branded product; absent means the product manages updates itself. */
|
|
44
|
+
readonly update?: BrandUpdateChannel;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parses a brand profile. Returns undefined for absent, malformed, or nameless input; a
|
|
48
|
+
* malformed profile is reported once on stderr and never throws, because a broken brand
|
|
49
|
+
* must not stop the agent from starting.
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseBrandProfile(raw: string | undefined): BrandProfile | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Parses the brand profile without touching the environment.
|
|
54
|
+
*
|
|
55
|
+
* The CLI entrypoint re-spawns the real agent as a child process and hands it `process.env`,
|
|
56
|
+
* so the variable has to survive that hop. Scrubbing therefore happens explicitly in the
|
|
57
|
+
* process that actually runs the agent - see `scrubBrandFromEnvironment`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function consumeBrandProfile(env?: NodeJS.ProcessEnv): BrandProfile | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Removes the brand variable so tools spawning the engine again inherit a clean environment
|
|
62
|
+
* and keep the engine's own identity. Called once the profile has been resolved by the
|
|
63
|
+
* process that runs the agent loop.
|
|
64
|
+
*/
|
|
65
|
+
export declare function scrubBrandFromEnvironment(env?: NodeJS.ProcessEnv): void;
|
|
66
|
+
/**
|
|
67
|
+
* The active brand profile, resolved (and scrubbed from the environment) on first use.
|
|
68
|
+
*/
|
|
69
|
+
export declare function brandProfile(): BrandProfile | undefined;
|
|
70
|
+
/** exported for tests only */
|
|
71
|
+
export declare function resetBrandProfileForTests(): void;
|
|
72
|
+
/** Environment variable names for one setting, most specific first. */
|
|
73
|
+
export declare function brandEnvNames(suffix: string, profile?: BrandProfile | undefined): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Reads one setting across the brand's prefix and the legacy prefixes, returning the first
|
|
76
|
+
* DEFINED value so that an explicitly empty value keeps its existing meaning.
|
|
77
|
+
*/
|
|
78
|
+
export declare function envValue(suffix: string, env?: NodeJS.ProcessEnv): string | undefined;
|
|
79
|
+
//# sourceMappingURL=brand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/core/brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAClC,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oGAAoG;IACpG,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8FAA8F;IAC9F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;CACrC;AAiCD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAuCnF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,YAAY,GAAG,SAAS,CAElG;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,IAAI,CAEpF;AAWD;;GAEG;AACH,wBAAgB,YAAY,IAAI,YAAY,GAAG,SAAS,CAMvD;AAED,8BAA8B;AAC9B,wBAAgB,yBAAyB,IAAI,IAAI,CAGhD;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,2BAAiB,GAAG,MAAM,EAAE,CAKhF;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,GAAG,SAAS,CAMjG"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand profile resolution.
|
|
3
|
+
*
|
|
4
|
+
* A distribution that repackages this engine (for example the `omo-ai` package) injects a
|
|
5
|
+
* single JSON environment variable describing how the product presents itself. The engine
|
|
6
|
+
* parses it once at startup and then REMOVES it from the environment, so nested processes
|
|
7
|
+
* spawned by tools inherit a clean environment and keep the engine's own identity.
|
|
8
|
+
*
|
|
9
|
+
* Absent or malformed input leaves every brand-derived value at its standalone default, so a
|
|
10
|
+
* plain install behaves exactly as it did before this module existed.
|
|
11
|
+
*/
|
|
12
|
+
/** Environment variable carrying the JSON brand profile. */
|
|
13
|
+
export const BRAND_ENV_VAR = "SENPI_BRAND";
|
|
14
|
+
function readUpdateChannel(source) {
|
|
15
|
+
const update = source.update;
|
|
16
|
+
if (typeof update !== "object" || update === null || Array.isArray(update))
|
|
17
|
+
return undefined;
|
|
18
|
+
const channel = update;
|
|
19
|
+
const packageName = readString(channel, "packageName");
|
|
20
|
+
const command = readString(channel, "command");
|
|
21
|
+
if (!packageName || !command)
|
|
22
|
+
return undefined;
|
|
23
|
+
return {
|
|
24
|
+
packageName,
|
|
25
|
+
distTag: readString(channel, "distTag") || "latest",
|
|
26
|
+
command,
|
|
27
|
+
changelogUrl: readString(channel, "changelogUrl"),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A config directory names ONE entry inside the home directory. Anything carrying a separator or
|
|
32
|
+
* a parent reference would move agent state - and the migration that copies into it - somewhere
|
|
33
|
+
* the user never agreed to, so such a profile is rejected rather than sanitised.
|
|
34
|
+
*/
|
|
35
|
+
function isSafeConfigDirName(value) {
|
|
36
|
+
return value !== "." && value !== ".." && !/[\\/]/.test(value);
|
|
37
|
+
}
|
|
38
|
+
function readString(source, key) {
|
|
39
|
+
const value = source[key];
|
|
40
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parses a brand profile. Returns undefined for absent, malformed, or nameless input; a
|
|
44
|
+
* malformed profile is reported once on stderr and never throws, because a broken brand
|
|
45
|
+
* must not stop the agent from starting.
|
|
46
|
+
*/
|
|
47
|
+
export function parseBrandProfile(raw) {
|
|
48
|
+
if (!raw?.trim())
|
|
49
|
+
return undefined;
|
|
50
|
+
let parsed;
|
|
51
|
+
try {
|
|
52
|
+
parsed = JSON.parse(raw);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
process.stderr.write(`warning: ignoring malformed ${BRAND_ENV_VAR} (expected JSON)\n`);
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
59
|
+
process.stderr.write(`warning: ignoring malformed ${BRAND_ENV_VAR} (expected a JSON object)\n`);
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const source = parsed;
|
|
63
|
+
const name = readString(source, "name");
|
|
64
|
+
if (!name) {
|
|
65
|
+
process.stderr.write(`warning: ignoring ${BRAND_ENV_VAR} without a "name"\n`);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const configDir = readString(source, "configDir") || `.${name}`;
|
|
69
|
+
if (!isSafeConfigDirName(configDir)) {
|
|
70
|
+
process.stderr.write(`warning: ignoring ${BRAND_ENV_VAR} with an unsafe "configDir"\n`);
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
name,
|
|
75
|
+
displayVersion: readString(source, "displayVersion"),
|
|
76
|
+
configDir,
|
|
77
|
+
flatLayout: source.flatLayout === true,
|
|
78
|
+
envPrefix: (readString(source, "envPrefix") || name).toUpperCase(),
|
|
79
|
+
userAgent: readString(source, "userAgent") || name,
|
|
80
|
+
originator: readString(source, "originator"),
|
|
81
|
+
update: readUpdateChannel(source),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Parses the brand profile without touching the environment.
|
|
86
|
+
*
|
|
87
|
+
* The CLI entrypoint re-spawns the real agent as a child process and hands it `process.env`,
|
|
88
|
+
* so the variable has to survive that hop. Scrubbing therefore happens explicitly in the
|
|
89
|
+
* process that actually runs the agent - see `scrubBrandFromEnvironment`.
|
|
90
|
+
*/
|
|
91
|
+
export function consumeBrandProfile(env = process.env) {
|
|
92
|
+
return parseBrandProfile(env[BRAND_ENV_VAR]);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Removes the brand variable so tools spawning the engine again inherit a clean environment
|
|
96
|
+
* and keep the engine's own identity. Called once the profile has been resolved by the
|
|
97
|
+
* process that runs the agent loop.
|
|
98
|
+
*/
|
|
99
|
+
export function scrubBrandFromEnvironment(env = process.env) {
|
|
100
|
+
delete env[BRAND_ENV_VAR];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Environment prefixes read after the brand's own prefix, so a machine configured before the
|
|
104
|
+
* rebrand keeps working unchanged.
|
|
105
|
+
*/
|
|
106
|
+
const LEGACY_ENV_PREFIXES = ["SENPI", "PI"];
|
|
107
|
+
let cachedProfile;
|
|
108
|
+
let profileResolved = false;
|
|
109
|
+
/**
|
|
110
|
+
* The active brand profile, resolved (and scrubbed from the environment) on first use.
|
|
111
|
+
*/
|
|
112
|
+
export function brandProfile() {
|
|
113
|
+
if (!profileResolved) {
|
|
114
|
+
cachedProfile = consumeBrandProfile();
|
|
115
|
+
profileResolved = true;
|
|
116
|
+
}
|
|
117
|
+
return cachedProfile;
|
|
118
|
+
}
|
|
119
|
+
/** exported for tests only */
|
|
120
|
+
export function resetBrandProfileForTests() {
|
|
121
|
+
cachedProfile = undefined;
|
|
122
|
+
profileResolved = false;
|
|
123
|
+
}
|
|
124
|
+
/** Environment variable names for one setting, most specific first. */
|
|
125
|
+
export function brandEnvNames(suffix, profile = brandProfile()) {
|
|
126
|
+
const prefixes = [profile?.envPrefix, ...LEGACY_ENV_PREFIXES].filter((prefix) => typeof prefix === "string" && prefix.length > 0);
|
|
127
|
+
return [...new Set(prefixes)].map((prefix) => `${prefix}_${suffix}`);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Reads one setting across the brand's prefix and the legacy prefixes, returning the first
|
|
131
|
+
* DEFINED value so that an explicitly empty value keeps its existing meaning.
|
|
132
|
+
*/
|
|
133
|
+
export function envValue(suffix, env = process.env) {
|
|
134
|
+
for (const name of brandEnvNames(suffix)) {
|
|
135
|
+
const value = env[name];
|
|
136
|
+
if (value !== undefined)
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=brand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand.js","sourceRoot":"","sources":["../../src/core/brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAoC3C,SAAS,iBAAiB,CA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CAAC,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,GAAG,GAAsB,OAAO,CAAC,GAAG;IAC5E,KAAK,MAAM,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;IACvC,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Brand profile resolution.\n *\n * A distribution that repackages this engine (for example the `omo-ai` package) injects a\n * single JSON environment variable describing how the product presents itself. The engine\n * parses it once at startup and then REMOVES it from the environment, so nested processes\n * spawned by tools inherit a clean environment and keep the engine's own identity.\n *\n * Absent or malformed input leaves every brand-derived value at its standalone default, so a\n * plain install behaves exactly as it did before this module existed.\n */\n\n/** Environment variable carrying the JSON brand profile. */\nexport const BRAND_ENV_VAR = \"SENPI_BRAND\";\n\n/**\n * Where a repackaging distribution publishes itself. Without this the engine keeps checking\n * its own package, which would advertise an update the branded product cannot install.\n */\nexport interface BrandUpdateChannel {\n\t/** Registry package that ships the branded product, e.g. `omo-ai`. */\n\treadonly packageName: string;\n\t/** Dist-tag the product publishes on, e.g. `beta`. */\n\treadonly distTag: string;\n\t/** Command shown to the user, e.g. `npm i -g omo-ai@beta`. */\n\treadonly command: string;\n\t/** Release notes URL; `{version}` is replaced with the available version. */\n\treadonly changelogUrl?: string;\n}\n\nexport interface BrandProfile {\n\t/** Product name shown to users and to the model. */\n\treadonly name: string;\n\t/** Version shown in the header, terminal titles and `--version`. */\n\treadonly displayVersion?: string;\n\t/** Config directory name, e.g. `.omo`. */\n\treadonly configDir: string;\n\t/** When true the agent state lives directly under the config directory, with no `agent` segment. */\n\treadonly flatLayout: boolean;\n\t/** Prefix for the product's environment variables, e.g. `OMO`. */\n\treadonly envPrefix: string;\n\t/** Product token used in the outgoing user agent. */\n\treadonly userAgent: string;\n\t/** Product token used as the provider-side originator, when the distribution overrides it. */\n\treadonly originator?: string;\n\t/** Update channel of the branded product; absent means the product manages updates itself. */\n\treadonly update?: BrandUpdateChannel;\n}\n\nfunction readUpdateChannel(source: Record<string, unknown>): BrandUpdateChannel | undefined {\n\tconst update = source.update;\n\tif (typeof update !== \"object\" || update === null || Array.isArray(update)) return undefined;\n\n\tconst channel = update as Record<string, unknown>;\n\tconst packageName = readString(channel, \"packageName\");\n\tconst command = readString(channel, \"command\");\n\tif (!packageName || !command) return undefined;\n\n\treturn {\n\t\tpackageName,\n\t\tdistTag: readString(channel, \"distTag\") || \"latest\",\n\t\tcommand,\n\t\tchangelogUrl: readString(channel, \"changelogUrl\"),\n\t};\n}\n\n/**\n * A config directory names ONE entry inside the home directory. Anything carrying a separator or\n * a parent reference would move agent state - and the migration that copies into it - somewhere\n * the user never agreed to, so such a profile is rejected rather than sanitised.\n */\nfunction isSafeConfigDirName(value: string): boolean {\n\treturn value !== \".\" && value !== \"..\" && !/[\\\\/]/.test(value);\n}\n\nfunction readString(source: Record<string, unknown>, key: string): string | undefined {\n\tconst value = source[key];\n\treturn typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\n/**\n * Parses a brand profile. Returns undefined for absent, malformed, or nameless input; a\n * malformed profile is reported once on stderr and never throws, because a broken brand\n * must not stop the agent from starting.\n */\nexport function parseBrandProfile(raw: string | undefined): BrandProfile | undefined {\n\tif (!raw?.trim()) return undefined;\n\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\tprocess.stderr.write(`warning: ignoring malformed ${BRAND_ENV_VAR} (expected JSON)\\n`);\n\t\treturn undefined;\n\t}\n\n\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n\t\tprocess.stderr.write(`warning: ignoring malformed ${BRAND_ENV_VAR} (expected a JSON object)\\n`);\n\t\treturn undefined;\n\t}\n\n\tconst source = parsed as Record<string, unknown>;\n\tconst name = readString(source, \"name\");\n\tif (!name) {\n\t\tprocess.stderr.write(`warning: ignoring ${BRAND_ENV_VAR} without a \"name\"\\n`);\n\t\treturn undefined;\n\t}\n\n\tconst configDir = readString(source, \"configDir\") || `.${name}`;\n\tif (!isSafeConfigDirName(configDir)) {\n\t\tprocess.stderr.write(`warning: ignoring ${BRAND_ENV_VAR} with an unsafe \"configDir\"\\n`);\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tname,\n\t\tdisplayVersion: readString(source, \"displayVersion\"),\n\t\tconfigDir,\n\t\tflatLayout: source.flatLayout === true,\n\t\tenvPrefix: (readString(source, \"envPrefix\") || name).toUpperCase(),\n\t\tuserAgent: readString(source, \"userAgent\") || name,\n\t\toriginator: readString(source, \"originator\"),\n\t\tupdate: readUpdateChannel(source),\n\t};\n}\n\n/**\n * Parses the brand profile without touching the environment.\n *\n * The CLI entrypoint re-spawns the real agent as a child process and hands it `process.env`,\n * so the variable has to survive that hop. Scrubbing therefore happens explicitly in the\n * process that actually runs the agent - see `scrubBrandFromEnvironment`.\n */\nexport function consumeBrandProfile(env: NodeJS.ProcessEnv = process.env): BrandProfile | undefined {\n\treturn parseBrandProfile(env[BRAND_ENV_VAR]);\n}\n\n/**\n * Removes the brand variable so tools spawning the engine again inherit a clean environment\n * and keep the engine's own identity. Called once the profile has been resolved by the\n * process that runs the agent loop.\n */\nexport function scrubBrandFromEnvironment(env: NodeJS.ProcessEnv = process.env): void {\n\tdelete env[BRAND_ENV_VAR];\n}\n\n/**\n * Environment prefixes read after the brand's own prefix, so a machine configured before the\n * rebrand keeps working unchanged.\n */\nconst LEGACY_ENV_PREFIXES = [\"SENPI\", \"PI\"] as const;\n\nlet cachedProfile: BrandProfile | undefined;\nlet profileResolved = false;\n\n/**\n * The active brand profile, resolved (and scrubbed from the environment) on first use.\n */\nexport function brandProfile(): BrandProfile | undefined {\n\tif (!profileResolved) {\n\t\tcachedProfile = consumeBrandProfile();\n\t\tprofileResolved = true;\n\t}\n\treturn cachedProfile;\n}\n\n/** exported for tests only */\nexport function resetBrandProfileForTests(): void {\n\tcachedProfile = undefined;\n\tprofileResolved = false;\n}\n\n/** Environment variable names for one setting, most specific first. */\nexport function brandEnvNames(suffix: string, profile = brandProfile()): string[] {\n\tconst prefixes = [profile?.envPrefix, ...LEGACY_ENV_PREFIXES].filter(\n\t\t(prefix): prefix is string => typeof prefix === \"string\" && prefix.length > 0,\n\t);\n\treturn [...new Set(prefixes)].map((prefix) => `${prefix}_${suffix}`);\n}\n\n/**\n * Reads one setting across the brand's prefix and the legacy prefixes, returning the first\n * DEFINED value so that an explicitly empty value keeps its existing meaning.\n */\nexport function envValue(suffix: string, env: NodeJS.ProcessEnv = process.env): string | undefined {\n\tfor (const name of brandEnvNames(suffix)) {\n\t\tconst value = env[name];\n\t\tif (value !== undefined) return value;\n\t}\n\treturn undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/identity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/identity.ts"],"names":[],"mappings":"AAEA,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { APP_NAME } from "../../config.js";
|
|
1
2
|
export function buildIdentitySection() {
|
|
2
|
-
return
|
|
3
|
+
return `You are ${APP_NAME}, a coding agent. Your work should be indistinguishable from a careful senior engineer's.`;
|
|
3
4
|
}
|
|
4
5
|
//# sourceMappingURL=identity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/identity.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB;IACnC,OAAO,
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/core/dynamic-prompt/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,UAAU,oBAAoB;IACnC,OAAO,WAAW,QAAQ,2FAA2F,CAAC;AACvH,CAAC","sourcesContent":["import { APP_NAME } from \"../../config.ts\";\n\nexport function buildIdentitySection(): string {\n\treturn `You are ${APP_NAME}, a coding agent. Your work should be indistinguishable from a careful senior engineer's.`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.d.ts","sourceRoot":"","sources":["../../src/core/experimental.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"experimental.d.ts","sourceRoot":"","sources":["../../src/core/experimental.ts"],"names":[],"mappings":"AACA,wBAAgB,8BAA8B,IAAI,OAAO,CAExD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","sourceRoot":"","sources":["../../src/core/experimental.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,8BAA8B;IAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"experimental.js","sourceRoot":"","sources":["../../src/core/experimental.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,MAAM,UAAU,8BAA8B;IAC7C,OAAO,QAAQ,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC;AACzC,CAAC","sourcesContent":["import { envValue } from \"./brand.ts\";\nexport function areExperimentalFeaturesEnabled(): boolean {\n\treturn envValue(\"EXPERIMENTAL\") === \"1\";\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-commit-boundary.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAI9D,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,WAAW,GAAG,cAAc,CAAC;AAE5E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"session-commit-boundary.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAI9D,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,WAAW,GAAG,cAAc,CAAC;AAE5E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAgBtE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMvF;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAEpE;AAED;;;;;GAKG;AACH,qBAAa,uBAAuB;IACnC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA6B;IAEhE,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAEjE;IAED,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,sBAAsB,CAMtF;IAED,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAExB;CACD"}
|
|
@@ -6,7 +6,16 @@ export function assistantContentHash(message) {
|
|
|
6
6
|
api: message.api,
|
|
7
7
|
provider: message.provider,
|
|
8
8
|
model: message.model,
|
|
9
|
-
content: message.content
|
|
9
|
+
content: message.content.map((block) => {
|
|
10
|
+
if (block.type !== "thinking")
|
|
11
|
+
return block;
|
|
12
|
+
// Agent-core stamps these display-only fields after the final
|
|
13
|
+
// message_update; every semantic thinking field stays fail-closed.
|
|
14
|
+
const stableBlock = { ...block };
|
|
15
|
+
delete stableBlock.startedAt;
|
|
16
|
+
delete stableBlock.endedAt;
|
|
17
|
+
return stableBlock;
|
|
18
|
+
}),
|
|
10
19
|
});
|
|
11
20
|
}
|
|
12
21
|
export function isResidentAssistant(message, modelId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-commit-boundary.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItD,MAAM,UAAU,oBAAoB,CAAC,OAAyB;IAC7D,OAAO,iBAAiB,CAAC;QACxB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,OAAO,CAAC,OAAO;
|
|
1
|
+
{"version":3,"file":"session-commit-boundary.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/claude-sdk-oauth/session-commit-boundary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItD,MAAM,UAAU,oBAAoB,CAAC,OAAyB;IAC7D,OAAO,iBAAiB,CAAC;QACxB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACtC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;gBAAE,OAAO,KAAK,CAAC;YAC5C,8DAA8D;YAC9D,mEAAmE;YACnE,MAAM,WAAW,G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C,GAAW;QACjB,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;CACD","sourcesContent":["import type { AssistantMessage } from \"@earendil-works/pi-ai\";\nimport { CLAUDE_SDK_OAUTH_PROVIDER_ID } from \"./account-management.ts\";\nimport { sessionSyncDigest } from \"./session-sync.ts\";\n\nexport type AssistantCommitOutcome = \"clean\" | \"rewritten\" | \"not-resident\";\n\nexport function assistantContentHash(message: AssistantMessage): string {\n\treturn sessionSyncDigest({\n\t\trole: message.role,\n\t\tapi: message.api,\n\t\tprovider: message.provider,\n\t\tmodel: message.model,\n\t\tcontent: message.content.map((block) => {\n\t\t\tif (block.type !== \"thinking\") return block;\n\t\t\t// Agent-core stamps these display-only fields after the final\n\t\t\t// message_update; every semantic thinking field stays fail-closed.\n\t\t\tconst stableBlock = { ...block };\n\t\t\tdelete stableBlock.startedAt;\n\t\t\tdelete stableBlock.endedAt;\n\t\t\treturn stableBlock;\n\t\t}),\n\t});\n}\n\nexport function isResidentAssistant(message: AssistantMessage, modelId: string): boolean {\n\treturn (\n\t\tmessage.api === CLAUDE_SDK_OAUTH_PROVIDER_ID &&\n\t\tmessage.provider === CLAUDE_SDK_OAUTH_PROVIDER_ID &&\n\t\tmessage.model === modelId\n\t);\n}\n\nexport function isTerminalFailure(message: AssistantMessage): boolean {\n\treturn message.stopReason === \"error\" || message.stopReason === \"aborted\";\n}\n\n/**\n * Divergence is decided by comparing what the provider streamed against what the\n * session ledger committed, never by in-flight staging: a result-only turn fills\n * its content at the terminal message with no preceding delta, so a staged-hash\n * comparison reports false divergence on a perfectly valid SDK response shape.\n */\nexport class AssistantCommitBoundary {\n\tprivate readonly providerFinalByKey = new Map<string, string>();\n\n\tcaptureProviderFinal(key: string, message: AssistantMessage): void {\n\t\tthis.providerFinalByKey.set(key, assistantContentHash(message));\n\t}\n\n\tcommit(key: string, message: AssistantMessage, modelId: string): AssistantCommitOutcome {\n\t\tconst providerFinal = this.providerFinalByKey.get(key);\n\t\tthis.providerFinalByKey.delete(key);\n\t\tif (!isResidentAssistant(message, modelId)) return \"not-resident\";\n\t\tif (providerFinal === undefined) return \"clean\";\n\t\treturn providerFinal === assistantContentHash(message) ? \"clean\" : \"rewritten\";\n\t}\n\n\tforget(key: string): void {\n\t\tthis.providerFinalByKey.delete(key);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/log.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/log.ts"],"names":[],"mappings":"AAyCA,MAAM,MAAM,qBAAqB,GAC9B,qBAAqB,GACrB,qBAAqB,GACrB,mBAAmB,GACnB,yBAAyB,GACzB,kBAAkB,GAClB,eAAe,GACf,sBAAsB,GACtB,UAAU,GACV,cAAc,GACd,mBAAmB,GACnB,oBAAoB,GACpB,iBAAiB,GACjB,qBAAqB,GACrB,cAAc,GACd,gBAAgB,CAAC;AAEpB,MAAM,WAAW,oBAAoB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAChC,KAAK,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACvE,IAAI,CAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACtE;AAED,MAAM,WAAW,uBAAuB;IACvC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,GAAE,uBAA4B,GACnC,gBAAgB,CA4BlB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { closeSync, mkdirSync, openSync, renameSync, statSync, writeSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
|
+
import { envValue } from "../../../brand.js";
|
|
3
4
|
const DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
|
|
4
5
|
const ALLOWED_KEYS = new Set([
|
|
5
6
|
"origin",
|
|
@@ -49,7 +50,7 @@ export function createCompactionLogger(agentDir, options = {}) {
|
|
|
49
50
|
return;
|
|
50
51
|
const line = formatLine(level, event, data);
|
|
51
52
|
writeLine(filePath, line, maxBytes, options.sink);
|
|
52
|
-
if (options.mirrorToStderr ??
|
|
53
|
+
if (options.mirrorToStderr ?? envValue("COMPACTION_DEBUG") === "1") {
|
|
53
54
|
console.error(DEBUG_PREFIX, line);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ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I,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACrC,IAAI,IAAI,KAAK,SAAS;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACzC,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["import { closeSync, mkdirSync, openSync, renameSync, statSync, writeSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\n\nconst DEFAULT_MAX_BYTES = 5 * 1024 * 1024;\nconst ALLOWED_KEYS = new Set([\n\t\"origin\",\n\t\"reason\",\n\t\"route\",\n\t\"variant\",\n\t\"generation\",\n\t\"requestId\",\n\t\"tokens\",\n\t\"tokensBefore\",\n\t\"savedTokens\",\n\t\"savingsRatio\",\n\t\"contextWindow\",\n\t\"threshold\",\n\t\"remainingSec\",\n\t\"count\",\n\t\"durationMs\",\n]);\nconst DEBUG_PREFIX = \"[senpi-compaction]\";\nconst EVENTS = new Set([\n\t\"speculative_started\",\n\t\"speculative_applied\",\n\t\"speculative_stale\",\n\t\"speculative_invalidated\",\n\t\"idle_trigger\",\n\t\"blocking_started\",\n\t\"warm_consumed\",\n\t\"core_route_generated\",\n\t\"skip_cap\",\n\t\"skip_breaker\",\n\t\"threshold_trigger\",\n\t\"hard_limit_trigger\",\n\t\"emergency_prune\",\n\t\"ineffective_counted\",\n\t\"summary_failed\",\n]);\n\nexport type CompactionLoggerEvent =\n\t| \"speculative_started\"\n\t| \"speculative_applied\"\n\t| \"speculative_stale\"\n\t| \"speculative_invalidated\"\n\t| \"blocking_started\"\n\t| \"warm_consumed\"\n\t| \"core_route_generated\"\n\t| \"skip_cap\"\n\t| \"skip_breaker\"\n\t| \"threshold_trigger\"\n\t| \"hard_limit_trigger\"\n\t| \"emergency_prune\"\n\t| \"ineffective_counted\"\n\t| \"idle_trigger\"\n\t| \"summary_failed\";\n\nexport interface CompactionLoggerData {\n\torigin?: string;\n\treason?: string;\n\troute?: string;\n\tvariant?: string;\n\tgeneration?: number;\n\trequestId?: string;\n\ttokens?: number;\n\ttokensBefore?: number;\n\tsavedTokens?: number;\n\tsavingsRatio?: number;\n\tcontextWindow?: number;\n\tthreshold?: number;\n\tremainingSec?: number;\n\tcount?: number;\n\tdurationMs?: number;\n}\n\nexport interface CompactionLogger {\n\tdebug(event: CompactionLoggerEvent, data?: CompactionLoggerData): void;\n\tinfo(event: CompactionLoggerEvent, data?: CompactionLoggerData): void;\n}\n\nexport interface CompactionLoggerOptions {\n\tsink?: (line: string) => void;\n\tmirrorToStderr?: boolean;\n\tmaxBytes?: number;\n}\n\nexport function createCompactionLogger(\n\tagentDir: string | undefined,\n\toptions: CompactionLoggerOptions = {},\n): CompactionLogger {\n\tif (typeof agentDir !== \"string\" || agentDir.length === 0) {\n\t\treturn { debug: () => {}, info: () => {} };\n\t}\n\tconst filePath = join(agentDir, \"logs\", \"compaction.log\");\n\tconst maxBytes = validMaxBytes(options.maxBytes);\n\tlet reportedFailure = false;\n\n\tfunction log(level: \"debug\" | \"info\", event: CompactionLoggerEvent, data?: CompactionLoggerData): void {\n\t\ttry {\n\t\t\tif (!EVENTS.has(event)) return;\n\t\t\tconst line = formatLine(level, event, data);\n\t\t\twriteLine(filePath, line, maxBytes, options.sink);\n\t\t\tif (options.mirrorToStderr ?? process.env.SENPI_COMPACTION_DEBUG === \"1\") {\n\t\t\t\tconsole.error(DEBUG_PREFIX, line);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!reportedFailure) {\n\t\t\t\treportedFailure = true;\n\t\t\t\tconsole.error(\"Unable to write compaction log\", error);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tdebug: (event, data) => log(\"debug\", event, data),\n\t\tinfo: (event, data) => log(\"info\", event, data),\n\t};\n}\n\nfunction validMaxBytes(value: number | undefined): number {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value > 0 ? Math.floor(value) : DEFAULT_MAX_BYTES;\n}\n\nfunction formatLine(level: \"debug\" | \"info\", event: CompactionLoggerEvent, data?: CompactionLoggerData): string {\n\tconst entry: Record<string, unknown> = { ts: new Date().toISOString(), level, event };\n\tif (data) {\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (!ALLOWED_KEYS.has(key)) continue;\n\t\t\tconst safeValue = safeValueOf(value, new WeakSet<object>());\n\t\t\tif (safeValue !== undefined) entry[key] = safeValue;\n\t\t}\n\t}\n\treturn JSON.stringify(entry);\n}\n\nfunction writeLine(filePath: string, line: string, maxBytes: number, sink?: (line: string) => void): void {\n\tconst text = `${line}\\n`;\n\tif (sink) sink(line);\n\tmkdirSync(dirname(filePath), { recursive: true, mode: 0o700 });\n\tif (needsRotate(filePath, Buffer.byteLength(text), maxBytes)) {\n\t\tconst rotated = `${filePath}.1`;\n\t\trenameSync(filePath, rotated);\n\t}\n\tconst fd = openSync(filePath, \"a\", 0o600);\n\ttry {\n\t\twriteSync(fd, text);\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\nfunction needsRotate(filePath: string, incomingBytes: number, maxBytes: number): boolean {\n\ttry {\n\t\treturn statSync(filePath).size + incomingBytes > maxBytes;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction safeValueOf(value: unknown, seen: WeakSet<object>): unknown {\n\tif (value === undefined) return undefined;\n\tif (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null)\n\t\treturn value;\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (typeof value === \"symbol\" || typeof value === \"function\") return String(value);\n\tif (typeof value !== \"object\") return String(value);\n\tif (seen.has(value)) return \"[Circular]\";\n\tseen.add(value);\n\tif (Array.isArray(value)) return value.map((item) => safeValueOf(item, seen));\n\tconst out: Record<string, unknown> = {};\n\tfor (const [key, item] of Object.entries(value)) {\n\t\tif (ALLOWED_KEYS.has(key)) {\n\t\t\tconst safe = safeValueOf(item, seen);\n\t\t\tif (safe !== undefined) out[key] = safe;\n\t\t}\n\t}\n\treturn out;\n}\n"]}
|
|
1
|
+
{"version":3,"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AAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACrC,IAAI,IAAI,KAAK,SAAS;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACzC,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["import { closeSync, mkdirSync, openSync, renameSync, statSync, writeSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { envValue } from \"../../../brand.ts\";\n\nconst DEFAULT_MAX_BYTES = 5 * 1024 * 1024;\nconst ALLOWED_KEYS = new Set([\n\t\"origin\",\n\t\"reason\",\n\t\"route\",\n\t\"variant\",\n\t\"generation\",\n\t\"requestId\",\n\t\"tokens\",\n\t\"tokensBefore\",\n\t\"savedTokens\",\n\t\"savingsRatio\",\n\t\"contextWindow\",\n\t\"threshold\",\n\t\"remainingSec\",\n\t\"count\",\n\t\"durationMs\",\n]);\nconst DEBUG_PREFIX = \"[senpi-compaction]\";\nconst EVENTS = new Set([\n\t\"speculative_started\",\n\t\"speculative_applied\",\n\t\"speculative_stale\",\n\t\"speculative_invalidated\",\n\t\"idle_trigger\",\n\t\"blocking_started\",\n\t\"warm_consumed\",\n\t\"core_route_generated\",\n\t\"skip_cap\",\n\t\"skip_breaker\",\n\t\"threshold_trigger\",\n\t\"hard_limit_trigger\",\n\t\"emergency_prune\",\n\t\"ineffective_counted\",\n\t\"summary_failed\",\n]);\n\nexport type CompactionLoggerEvent =\n\t| \"speculative_started\"\n\t| \"speculative_applied\"\n\t| \"speculative_stale\"\n\t| \"speculative_invalidated\"\n\t| \"blocking_started\"\n\t| \"warm_consumed\"\n\t| \"core_route_generated\"\n\t| \"skip_cap\"\n\t| \"skip_breaker\"\n\t| \"threshold_trigger\"\n\t| \"hard_limit_trigger\"\n\t| \"emergency_prune\"\n\t| \"ineffective_counted\"\n\t| \"idle_trigger\"\n\t| \"summary_failed\";\n\nexport interface CompactionLoggerData {\n\torigin?: string;\n\treason?: string;\n\troute?: string;\n\tvariant?: string;\n\tgeneration?: number;\n\trequestId?: string;\n\ttokens?: number;\n\ttokensBefore?: number;\n\tsavedTokens?: number;\n\tsavingsRatio?: number;\n\tcontextWindow?: number;\n\tthreshold?: number;\n\tremainingSec?: number;\n\tcount?: number;\n\tdurationMs?: number;\n}\n\nexport interface CompactionLogger {\n\tdebug(event: CompactionLoggerEvent, data?: CompactionLoggerData): void;\n\tinfo(event: CompactionLoggerEvent, data?: CompactionLoggerData): void;\n}\n\nexport interface CompactionLoggerOptions {\n\tsink?: (line: string) => void;\n\tmirrorToStderr?: boolean;\n\tmaxBytes?: number;\n}\n\nexport function createCompactionLogger(\n\tagentDir: string | undefined,\n\toptions: CompactionLoggerOptions = {},\n): CompactionLogger {\n\tif (typeof agentDir !== \"string\" || agentDir.length === 0) {\n\t\treturn { debug: () => {}, info: () => {} };\n\t}\n\tconst filePath = join(agentDir, \"logs\", \"compaction.log\");\n\tconst maxBytes = validMaxBytes(options.maxBytes);\n\tlet reportedFailure = false;\n\n\tfunction log(level: \"debug\" | \"info\", event: CompactionLoggerEvent, data?: CompactionLoggerData): void {\n\t\ttry {\n\t\t\tif (!EVENTS.has(event)) return;\n\t\t\tconst line = formatLine(level, event, data);\n\t\t\twriteLine(filePath, line, maxBytes, options.sink);\n\t\t\tif (options.mirrorToStderr ?? envValue(\"COMPACTION_DEBUG\") === \"1\") {\n\t\t\t\tconsole.error(DEBUG_PREFIX, line);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!reportedFailure) {\n\t\t\t\treportedFailure = true;\n\t\t\t\tconsole.error(\"Unable to write compaction log\", error);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tdebug: (event, data) => log(\"debug\", event, data),\n\t\tinfo: (event, data) => log(\"info\", event, data),\n\t};\n}\n\nfunction validMaxBytes(value: number | undefined): number {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value > 0 ? Math.floor(value) : DEFAULT_MAX_BYTES;\n}\n\nfunction formatLine(level: \"debug\" | \"info\", event: CompactionLoggerEvent, data?: CompactionLoggerData): string {\n\tconst entry: Record<string, unknown> = { ts: new Date().toISOString(), level, event };\n\tif (data) {\n\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\tif (!ALLOWED_KEYS.has(key)) continue;\n\t\t\tconst safeValue = safeValueOf(value, new WeakSet<object>());\n\t\t\tif (safeValue !== undefined) entry[key] = safeValue;\n\t\t}\n\t}\n\treturn JSON.stringify(entry);\n}\n\nfunction writeLine(filePath: string, line: string, maxBytes: number, sink?: (line: string) => void): void {\n\tconst text = `${line}\\n`;\n\tif (sink) sink(line);\n\tmkdirSync(dirname(filePath), { recursive: true, mode: 0o700 });\n\tif (needsRotate(filePath, Buffer.byteLength(text), maxBytes)) {\n\t\tconst rotated = `${filePath}.1`;\n\t\trenameSync(filePath, rotated);\n\t}\n\tconst fd = openSync(filePath, \"a\", 0o600);\n\ttry {\n\t\twriteSync(fd, text);\n\t} finally {\n\t\tcloseSync(fd);\n\t}\n}\n\nfunction needsRotate(filePath: string, incomingBytes: number, maxBytes: number): boolean {\n\ttry {\n\t\treturn statSync(filePath).size + incomingBytes > maxBytes;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction safeValueOf(value: unknown, seen: WeakSet<object>): unknown {\n\tif (value === undefined) return undefined;\n\tif (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || value === null)\n\t\treturn value;\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (typeof value === \"symbol\" || typeof value === \"function\") return String(value);\n\tif (typeof value !== \"object\") return String(value);\n\tif (seen.has(value)) return \"[Circular]\";\n\tseen.add(value);\n\tif (Array.isArray(value)) return value.map((item) => safeValueOf(item, seen));\n\tconst out: Record<string, unknown> = {};\n\tfor (const [key, item] of Object.entries(value)) {\n\t\tif (ALLOWED_KEYS.has(key)) {\n\t\t\tconst safe = safeValueOf(item, seen);\n\t\t\tif (safe !== undefined) out[key] = safe;\n\t\t}\n\t}\n\treturn out;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-shim-filter.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/config-reload/generated-shim-filter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generated-shim-filter.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/config-reload/generated-shim-filter.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAEnG"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
|
-
|
|
3
|
+
import { hasGeneratedShimBanner } from "../../../generated-shim-banner.js";
|
|
4
4
|
function isInsideExtensionsDirectory(path, agentDir) {
|
|
5
5
|
return resolve(dirname(path)) === resolve(agentDir, "extensions");
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function isGeneratedShim(path) {
|
|
8
8
|
try {
|
|
9
|
-
return readFileSync(path, "utf-8")
|
|
9
|
+
return hasGeneratedShimBanner(readFileSync(path, "utf-8"));
|
|
10
10
|
}
|
|
11
11
|
catch {
|
|
12
12
|
return false;
|
|
@@ -27,6 +27,6 @@ function hasGeneratedShimBanner(path) {
|
|
|
27
27
|
* again.
|
|
28
28
|
*/
|
|
29
29
|
export function excludeGeneratedExtensionShims(paths, agentDir) {
|
|
30
|
-
return paths.filter((path) => !(isInsideExtensionsDirectory(path, agentDir) &&
|
|
30
|
+
return paths.filter((path) => !(isInsideExtensionsDirectory(path, agentDir) && isGeneratedShim(path)));
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=generated-shim-filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-shim-filter.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/config-reload/generated-shim-filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"generated-shim-filter.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/config-reload/generated-shim-filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,SAAS,2BAA2B,CAAC,IAAY,EAAE,QAAgB;IAClE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACpC,IAAI,CAAC;QACJ,OAAO,sBAAsB,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,8BAA8B,CAAC,KAAwB,EAAE,QAAgB;IACxF,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,2BAA2B,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxG,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { hasGeneratedShimBanner } from \"../../../generated-shim-banner.ts\";\n\nfunction isInsideExtensionsDirectory(path: string, agentDir: string): boolean {\n\treturn resolve(dirname(path)) === resolve(agentDir, \"extensions\");\n}\n\nfunction isGeneratedShim(path: string): boolean {\n\ttry {\n\t\treturn hasGeneratedShimBanner(readFileSync(path, \"utf-8\"));\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Drops changes to senpi's own generated global-default extension shims.\n *\n * The shim records the running build's absolute module path, so two sessions\n * that reached the same build by different paths (npm bin symlink versus the\n * real checkout), or two genuinely different builds, rewrite it in a loop:\n * every rewrite reloads every other session, which rewrites it back. A running\n * session already loaded its own extensions, so another session's shim rewrite\n * is never a reason to reload. Content-based like the routine-settings filter,\n * because the self-write tracker is process-local and cannot see siblings.\n *\n * A shim the user replaced with real content loses the banner and is watched\n * again.\n */\nexport function excludeGeneratedExtensionShims(paths: readonly string[], agentDir: string): string[] {\n\treturn paths.filter((path) => !(isInsideExtensionsDirectory(path, agentDir) && isGeneratedShim(path)));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAiCrE,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAiCrE,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CA2X5D"}
|
|
@@ -271,6 +271,11 @@ export default function goalExtension(pi) {
|
|
|
271
271
|
continuationPending = true;
|
|
272
272
|
},
|
|
273
273
|
});
|
|
274
|
+
if (continuedGoal === null) {
|
|
275
|
+
clearAgentGoalAccounting();
|
|
276
|
+
refreshGoalUiBestEffort(ctx, null);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
274
279
|
if (continuedGoal.status === goal.status)
|
|
275
280
|
return;
|
|
276
281
|
if (continuedGoal.status === "active")
|