@gajae-code/coding-agent 0.12.0 → 0.12.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/CHANGELOG.md +82 -1
- package/dist/types/async/job-manager.d.ts +17 -3
- package/dist/types/config/settings-schema.d.ts +54 -0
- package/dist/types/exa/mcp-client.d.ts +10 -1
- package/dist/types/exec/bash-executor.d.ts +45 -12
- package/dist/types/extensibility/extensions/types.d.ts +16 -2
- package/dist/types/extensibility/gjc-plugins/index.d.ts +12 -2
- package/dist/types/extensibility/gjc-plugins/installer.d.ts +63 -7
- package/dist/types/extensibility/gjc-plugins/lifecycle-reconciliation.d.ts +55 -0
- package/dist/types/extensibility/gjc-plugins/lifecycle.d.ts +64 -0
- package/dist/types/extensibility/gjc-plugins/runtime-quarantine.d.ts +67 -0
- package/dist/types/extensibility/gjc-plugins/session-validation.d.ts +3 -1
- package/dist/types/extensibility/gjc-plugins/types.d.ts +124 -0
- package/dist/types/gjc-runtime/launch-tmux.d.ts +1 -0
- package/dist/types/gjc-runtime/ralplan-runtime.d.ts +18 -0
- package/dist/types/gjc-runtime/team-launch.d.ts +1 -1
- package/dist/types/gjc-runtime/team-runtime.d.ts +25 -0
- package/dist/types/gjc-runtime/team-worker-heartbeat.d.ts +43 -0
- package/dist/types/gjc-runtime/tmux-owner-isolation.d.ts +10 -0
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +31 -80
- package/dist/types/modes/acp/acp-agent.d.ts +2 -19
- package/dist/types/modes/components/gjc-bundle-settings.d.ts +34 -0
- package/dist/types/modes/components/notifications-settings-editor.d.ts +1 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +18 -0
- package/dist/types/modes/components/settings-selector.d.ts +9 -0
- package/dist/types/modes/components/status-line/gh.d.ts +5 -0
- package/dist/types/modes/components/transcript-viewer-overlay.d.ts +18 -1
- package/dist/types/reminders/star-reminder.d.ts +3 -13
- package/dist/types/runtime-mcp/manager.d.ts +1 -0
- package/dist/types/sdk/acp/adapter.d.ts +3 -1
- package/dist/types/sdk/broker/transport.d.ts +2 -0
- package/dist/types/sdk/bus/attachment-registry.d.ts +1 -0
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +4 -1
- package/dist/types/sdk/bus/config.d.ts +6 -2
- package/dist/types/sdk/bus/index.d.ts +29 -0
- package/dist/types/sdk/bus/kind-aware-reconciliation.d.ts +8 -1
- package/dist/types/sdk/bus/lifecycle-control-runtime.d.ts +4 -0
- package/dist/types/sdk/bus/reconciliation-store.d.ts +7 -3
- package/dist/types/sdk/bus/rich-draft.d.ts +1 -0
- package/dist/types/sdk/bus/rich-render.d.ts +2 -0
- package/dist/types/sdk/bus/telegram-adoption-intent.d.ts +165 -0
- package/dist/types/sdk/bus/telegram-cli.d.ts +12 -0
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +11 -4
- package/dist/types/sdk/bus/telegram-daemon.d.ts +25 -1
- package/dist/types/sdk/bus/telegram-reference.d.ts +11 -1
- package/dist/types/sdk/bus/threaded-render.d.ts +3 -2
- package/dist/types/sdk/bus/topic-registry.d.ts +11 -1
- package/dist/types/sdk/host/query/revision-store.d.ts +2 -0
- package/dist/types/sdk/host/reverse-leases.d.ts +1 -1
- package/dist/types/sdk/prompt-status.d.ts +23 -3
- package/dist/types/sdk/session.d.ts +6 -0
- package/dist/types/session/agent-session.d.ts +38 -2
- package/dist/types/session/artifacts.d.ts +8 -0
- package/dist/types/session/blob-store.d.ts +57 -4
- package/dist/types/session/internal/managed-session-storage.d.ts +8 -1
- package/dist/types/session/session-manager.d.ts +23 -6
- package/dist/types/session/session-storage.d.ts +4 -0
- package/dist/types/session/streaming-output.d.ts +36 -7
- package/dist/types/setup/credential-import.d.ts +12 -0
- package/dist/types/skill-state/active-state.d.ts +12 -0
- package/dist/types/skill-state/workflow-hud.d.ts +6 -0
- package/dist/types/task/executor.d.ts +3 -2
- package/dist/types/task/index.d.ts +3 -1
- package/dist/types/task/provider-retry-status.d.ts +8 -0
- package/dist/types/task/receipt.d.ts +7 -1
- package/dist/types/task/types.d.ts +23 -0
- package/dist/types/tools/ask-answer-registry.d.ts +2 -2
- package/dist/types/tools/bash-interactive.d.ts +4 -1
- package/dist/types/tools/bash.d.ts +3 -1
- package/dist/types/tools/image-gen.d.ts +4 -0
- package/dist/types/tools/index.d.ts +4 -0
- package/dist/types/tools/output-meta.d.ts +23 -2
- package/dist/types/tools/path-utils.d.ts +1 -0
- package/dist/types/tools/read.d.ts +0 -6
- package/dist/types/tools/review.d.ts +5 -7
- package/dist/types/tools/subagent.d.ts +2 -0
- package/dist/types/utils/gh.d.ts +13 -0
- package/dist/types/utils/image-resize.d.ts +1 -0
- package/dist/types/web/search/providers/kimi.d.ts +2 -0
- package/dist/types/web/search/providers/searxng.d.ts +7 -0
- package/dist/types/web/search/providers/xai.d.ts +2 -0
- package/package.json +10 -8
- package/scripts/acp-conformance-agent.ts +218 -0
- package/scripts/capture-gjc-bundle-settings.ts +306 -0
- package/scripts/generate-sdk-operation-inventory.ts +3 -0
- package/scripts/resident-memory-bench.ts +1341 -0
- package/scripts/run-acp-conformance.ts +285 -0
- package/src/async/job-manager.ts +78 -20
- package/src/cli/fast-help.ts +1 -1
- package/src/cli/plugin-cli.ts +176 -18
- package/src/commands/team.ts +19 -1
- package/src/config/file-lock.ts +11 -2
- package/src/config/settings-schema.ts +51 -0
- package/src/coordinator-mcp/question-gate-codec.ts +1 -1
- package/src/coordinator-mcp/server.ts +5 -12
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +1 -0
- package/src/defaults/gjc/skills/ralplan/SKILL.md +19 -16
- package/src/defaults/gjc/skills/team/SKILL.md +2 -0
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +37 -24
- package/src/defaults/gjc/skills/ultragoal/validation-batch-contracts.md +12 -0
- package/src/defaults/gjc-defaults.ts +4 -4
- package/src/exa/mcp-client.ts +12 -3
- package/src/exec/bash-executor.ts +144 -27
- package/src/extensibility/extensions/runner.ts +15 -0
- package/src/extensibility/extensions/types.ts +18 -1
- package/src/extensibility/gjc-plugins/constrained-hooks.ts +8 -2
- package/src/extensibility/gjc-plugins/index.ts +19 -2
- package/src/extensibility/gjc-plugins/installer.ts +189 -50
- package/src/extensibility/gjc-plugins/lifecycle-reconciliation.ts +199 -0
- package/src/extensibility/gjc-plugins/lifecycle.ts +626 -0
- package/src/extensibility/gjc-plugins/observability.ts +3 -3
- package/src/extensibility/gjc-plugins/prompt-appendix.ts +5 -1
- package/src/extensibility/gjc-plugins/runtime-adapters.ts +12 -2
- package/src/extensibility/gjc-plugins/runtime-quarantine.ts +121 -0
- package/src/extensibility/gjc-plugins/schema.ts +84 -12
- package/src/extensibility/gjc-plugins/session-validation.ts +9 -3
- package/src/extensibility/gjc-plugins/types.ts +141 -0
- package/src/extensibility/gjc-plugins/validation.ts +9 -0
- package/src/gjc-runtime/launch-tmux.ts +25 -6
- package/src/gjc-runtime/managed-owner-admission.ts +1 -1
- package/src/gjc-runtime/ralplan-runtime.ts +411 -17
- package/src/gjc-runtime/team-launch.ts +8 -0
- package/src/gjc-runtime/team-runtime.ts +140 -32
- package/src/gjc-runtime/team-worker-heartbeat.ts +149 -0
- package/src/gjc-runtime/tmux-owner-isolation.ts +10 -0
- package/src/gjc-runtime/tmux-sessions.ts +58 -13
- package/src/gjc-runtime/ultragoal-runtime.ts +401 -611
- package/src/gjc-runtime/workflow-manifest.generated.json +8 -99
- package/src/gjc-runtime/workflow-manifest.ts +4 -68
- package/src/internal-urls/docs-index.generated.ts +15 -15
- package/src/modes/DESIGN.md +51 -0
- package/src/modes/acp/acp-agent.ts +298 -186
- package/src/modes/components/gjc-bundle-settings.ts +508 -0
- package/src/modes/components/notifications-settings-editor.ts +12 -1
- package/src/modes/components/oauth-selector.ts +68 -30
- package/src/modes/components/session-observer-overlay.ts +305 -86
- package/src/modes/components/settings-selector.ts +56 -5
- package/src/modes/components/status-line/gh.ts +16 -0
- package/src/modes/components/tool-status-header.ts +3 -14
- package/src/modes/components/transcript-viewer-overlay.ts +99 -24
- package/src/modes/controllers/command-controller.ts +4 -0
- package/src/modes/controllers/extension-ui-controller.ts +7 -0
- package/src/modes/controllers/selector-controller.ts +45 -0
- package/src/modes/runtime-init.ts +3 -0
- package/src/prompts/agent-fragments/ralplan-persistence.md +4 -3
- package/src/prompts/system/eager-todo.md +8 -4
- package/src/prompts/system/system-prompt.md +11 -4
- package/src/prompts/tools/bash.md +5 -5
- package/src/prompts/tools/search-tool-bm25.md +5 -0
- package/src/prompts/tools/task.md +1 -1
- package/src/reminders/star-reminder.ts +4 -42
- package/src/runtime-mcp/manager.ts +19 -4
- package/src/sdk/acp/adapter.ts +22 -6
- package/src/sdk/broker/transport.ts +35 -3
- package/src/sdk/bus/attachment-registry.ts +5 -1
- package/src/sdk/bus/chat-daemon-cli.ts +4 -39
- package/src/sdk/bus/chat-daemon-control.ts +6 -3
- package/src/sdk/bus/config.ts +18 -2
- package/src/sdk/bus/index.ts +661 -126
- package/src/sdk/bus/kind-aware-reconciliation.ts +148 -73
- package/src/sdk/bus/lifecycle-commands.ts +4 -1
- package/src/sdk/bus/lifecycle-control-runtime.ts +403 -88
- package/src/sdk/bus/reconciliation-store.ts +95 -16
- package/src/sdk/bus/rich-draft.ts +1 -1
- package/src/sdk/bus/rich-render.ts +2 -2
- package/src/sdk/bus/telegram-adoption-intent.ts +574 -0
- package/src/sdk/bus/telegram-cli.ts +33 -8
- package/src/sdk/bus/telegram-daemon-cli.ts +1 -0
- package/src/sdk/bus/telegram-daemon-contract.ts +11 -4
- package/src/sdk/bus/telegram-daemon.ts +916 -23
- package/src/sdk/bus/telegram-reference.ts +40 -3
- package/src/sdk/bus/threaded-render.ts +48 -3
- package/src/sdk/bus/topic-registry.ts +20 -0
- package/src/sdk/host/query/revision-store.ts +36 -2
- package/src/sdk/host/reverse-leases.ts +44 -7
- package/src/sdk/prompt-status.ts +16 -3
- package/src/sdk/protocol/operation-inventory.generated.json +22 -0
- package/src/sdk/session.ts +88 -9
- package/src/session/agent-session.ts +822 -172
- package/src/session/artifacts.ts +22 -0
- package/src/session/auth-broker-config.ts +10 -3
- package/src/session/blob-store.ts +915 -24
- package/src/session/internal/managed-session-scope.ts +44 -6
- package/src/session/internal/managed-session-storage.ts +48 -6
- package/src/session/session-manager.ts +1614 -435
- package/src/session/session-storage.ts +9 -1
- package/src/session/streaming-output.ts +238 -68
- package/src/setup/credential-import.ts +75 -13
- package/src/skill-state/active-state.ts +32 -0
- package/src/skill-state/workflow-hud.ts +17 -0
- package/src/skill-state/workflow-mutation-guard.ts +496 -2
- package/src/task/executor.ts +122 -39
- package/src/task/index.ts +23 -14
- package/src/task/provider-retry-status.ts +16 -0
- package/src/task/receipt.ts +23 -7
- package/src/task/render.ts +6 -2
- package/src/task/types.ts +108 -0
- package/src/tools/ask-answer-registry.ts +12 -6
- package/src/tools/ask.ts +86 -55
- package/src/tools/ast-edit.ts +1 -0
- package/src/tools/ast-grep.ts +1 -0
- package/src/tools/bash-interactive.ts +8 -3
- package/src/tools/bash.ts +503 -60
- package/src/tools/find.ts +1 -0
- package/src/tools/image-gen.ts +29 -5
- package/src/tools/index.ts +4 -0
- package/src/tools/output-meta.ts +108 -14
- package/src/tools/path-utils.ts +3 -2
- package/src/tools/read.ts +18 -0
- package/src/tools/review.ts +5 -7
- package/src/tools/search.ts +1 -0
- package/src/tools/subagent-render.ts +6 -2
- package/src/tools/subagent.ts +6 -0
- package/src/tools/telegram-send.ts +6 -3
- package/src/utils/gh.ts +39 -0
- package/src/utils/image-resize.ts +3 -0
- package/src/web/search/providers/anthropic.ts +4 -4
- package/src/web/search/providers/kimi.ts +15 -5
- package/src/web/search/providers/searxng.ts +47 -4
- package/src/web/search/providers/xai.ts +7 -2
- package/dist/types/gjc-runtime/ultragoal-pipeline.d.ts +0 -23
- package/src/defaults/gjc/skills/ultragoal/pipeline-validation-contracts.md +0 -30
- package/src/gjc-runtime/ultragoal-pipeline.ts +0 -306
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Container } from "@gajae-code/tui";
|
|
2
|
+
import { type GjcLifecycleContext } from "../../extensibility/gjc-plugins/lifecycle";
|
|
3
|
+
import { type GjcRuntimeSnapshotProvider } from "../../extensibility/gjc-plugins/runtime-quarantine";
|
|
4
|
+
import type { GjcBundleIdentity, GjcBundleSummary, GjcLifecycleResult, GjcReviewedUpdateToken, GjcToggleResult, GjcUpdateApplyResult, GjcUpdatePreview } from "../../extensibility/gjc-plugins/types";
|
|
5
|
+
/** Injectable lifecycle boundary; Settings never reads registries or executes bundle code. */
|
|
6
|
+
export interface GjcBundleLifecyclePort {
|
|
7
|
+
listGjcBundles(ctx: GjcLifecycleContext): Promise<GjcBundleSummary[]>;
|
|
8
|
+
getGjcBundle(ctx: GjcLifecycleContext, identity: GjcBundleIdentity): Promise<GjcLifecycleResult<GjcBundleSummary>>;
|
|
9
|
+
previewGjcBundleUpdate(ctx: GjcLifecycleContext, identity: GjcBundleIdentity): Promise<GjcLifecycleResult<GjcUpdatePreview>>;
|
|
10
|
+
applyGjcBundleUpdate(ctx: GjcLifecycleContext, token: GjcReviewedUpdateToken): Promise<GjcLifecycleResult<GjcUpdateApplyResult>>;
|
|
11
|
+
setGjcBundleEnabled(ctx: GjcLifecycleContext, identity: GjcBundleIdentity, enabled: boolean): Promise<GjcLifecycleResult<GjcToggleResult>>;
|
|
12
|
+
setGjcBundleSurfaceEnabled(ctx: GjcLifecycleContext, identity: GjcBundleIdentity, surfaceId: string, enabled: boolean): Promise<GjcLifecycleResult<GjcToggleResult>>;
|
|
13
|
+
}
|
|
14
|
+
export interface GjcBundleSettingsDependencies {
|
|
15
|
+
lifecycle?: GjcBundleLifecyclePort;
|
|
16
|
+
runtimeSnapshotProvider?: GjcRuntimeSnapshotProvider;
|
|
17
|
+
activationGeneration?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface GjcBundleSettingsCallbacks {
|
|
20
|
+
onClose: () => void;
|
|
21
|
+
onBundlesChanged?: () => void;
|
|
22
|
+
}
|
|
23
|
+
export type GjcBundleSettingsState = "loading" | "error" | "empty" | "list" | "detail" | "unsupported-source" | "update-review" | "update-confirm" | "update-running" | "update-result" | "stale-result" | "quarantined-blocked" | "mutation-in-flight-locked";
|
|
24
|
+
/** Scope-qualified, lifecycle-backed Settings UI for installed GJC bundles. */
|
|
25
|
+
export declare class GjcBundleSettingsComponent extends Container {
|
|
26
|
+
#private;
|
|
27
|
+
private readonly callbacks;
|
|
28
|
+
private readonly dependencies;
|
|
29
|
+
constructor(cwd: string, callbacks: GjcBundleSettingsCallbacks, dependencies?: GjcBundleSettingsDependencies);
|
|
30
|
+
get stateId(): GjcBundleSettingsState;
|
|
31
|
+
get navigationLocked(): boolean;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
handleInput(data: string): void;
|
|
34
|
+
}
|
|
@@ -12,6 +12,7 @@ export interface NotificationsEditorPreferences {
|
|
|
12
12
|
richDraftEnabled: boolean;
|
|
13
13
|
toolActivityEnabled: boolean;
|
|
14
14
|
streamingEnabled: boolean;
|
|
15
|
+
sound: "all" | "important" | "none";
|
|
15
16
|
}
|
|
16
17
|
/** Secret-safe snapshot used to render the Notifications tab. */
|
|
17
18
|
export interface NotificationsEditorState {
|
|
@@ -2,6 +2,24 @@ import type { KeyId } from "../../config/keybindings";
|
|
|
2
2
|
import type { SessionMessageEntry } from "../../session/session-manager";
|
|
3
3
|
import type { SessionObserverRegistry } from "../session-observer-registry";
|
|
4
4
|
import { type TranscriptViewerEntry, TranscriptViewerOverlay } from "./transcript-viewer-overlay";
|
|
5
|
+
export declare const __sessionObserverProjectionCounters: {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
projectionFullRuns: number;
|
|
8
|
+
projectionIncrementalRuns: number;
|
|
9
|
+
sourceMessagesProjected: number;
|
|
10
|
+
projectedEntriesAppended: number;
|
|
11
|
+
resultPatchCount: number;
|
|
12
|
+
snapshot(): {
|
|
13
|
+
projectionFullRuns: number;
|
|
14
|
+
projectionIncrementalRuns: number;
|
|
15
|
+
sourceMessagesProjected: number;
|
|
16
|
+
projectedEntriesAppended: number;
|
|
17
|
+
resultPatchCount: number;
|
|
18
|
+
};
|
|
19
|
+
enable(): void;
|
|
20
|
+
disable(): void;
|
|
21
|
+
reset(): void;
|
|
22
|
+
};
|
|
5
23
|
/** Session-observer adapter. The shared viewer owns navigation and fold state. */
|
|
6
24
|
export declare class SessionObserverOverlayComponent extends TranscriptViewerOverlay {
|
|
7
25
|
#private;
|
|
@@ -3,6 +3,7 @@ import type { Effort } from "@gajae-code/ai";
|
|
|
3
3
|
import { type Component, Container } from "@gajae-code/tui";
|
|
4
4
|
import { type SettingPath } from "../../config/settings";
|
|
5
5
|
import type { StatusLinePreset, StatusLineSegmentId, StatusLineSeparatorStyle } from "../../config/settings-schema";
|
|
6
|
+
import type { GjcRuntimeSnapshotProvider } from "../../extensibility/gjc-plugins/runtime-quarantine";
|
|
6
7
|
import { type NotificationsEditorOperations } from "./notifications-settings-editor";
|
|
7
8
|
import type { StatusLineSegmentOptions } from "./tool-status-header";
|
|
8
9
|
/**
|
|
@@ -24,6 +25,14 @@ export interface SettingsRuntimeContext {
|
|
|
24
25
|
petAvailable?: boolean;
|
|
25
26
|
/** Terminal environment used to select unavailable-pet guidance. Omitted in production to use Bun.env. */
|
|
26
27
|
terminalEnv?: NodeJS.ProcessEnv;
|
|
28
|
+
/**
|
|
29
|
+
* Runtime evidence published by the session for the current activation
|
|
30
|
+
* generation. Omitted when no session published one, in which case the GJC
|
|
31
|
+
* Bundles tab honestly reports runtime status as unavailable.
|
|
32
|
+
*/
|
|
33
|
+
gjcRuntimeSnapshot?: GjcRuntimeSnapshotProvider;
|
|
34
|
+
/** Activation generation the published snapshot must match to be merged. */
|
|
35
|
+
gjcActivationGeneration?: number;
|
|
27
36
|
}
|
|
28
37
|
/** Status line settings subset for preview */
|
|
29
38
|
export interface StatusLinePreviewSettings {
|
|
@@ -29,13 +29,30 @@ export type TranscriptViewerOverlayOptions = {
|
|
|
29
29
|
footerControls?: string;
|
|
30
30
|
getEntryText?: (entry: TranscriptViewerEntry, expanded: boolean) => string;
|
|
31
31
|
};
|
|
32
|
+
export declare const __transcriptViewerPerfCounters: {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
layoutCacheHits: number;
|
|
35
|
+
layoutCacheMisses: number;
|
|
36
|
+
refreshRuns: number;
|
|
37
|
+
rebuildRuns: number;
|
|
38
|
+
snapshot(): {
|
|
39
|
+
layoutCacheHits: number;
|
|
40
|
+
layoutCacheMisses: number;
|
|
41
|
+
refreshRuns: number;
|
|
42
|
+
rebuildRuns: number;
|
|
43
|
+
};
|
|
44
|
+
enable(): void;
|
|
45
|
+
disable(): void;
|
|
46
|
+
reset(): void;
|
|
47
|
+
};
|
|
32
48
|
/** Message-agnostic, modal transcript browser over resolved projection entries. */
|
|
33
49
|
export declare class TranscriptViewerOverlay extends Container {
|
|
34
50
|
#private;
|
|
35
51
|
constructor(options: TranscriptViewerOverlayOptions);
|
|
36
52
|
get selectedEntryId(): string | undefined;
|
|
37
53
|
get isFullscreen(): boolean;
|
|
38
|
-
refresh(identityMap?: ReadonlyMap<string, string
|
|
54
|
+
refresh(identityMap?: ReadonlyMap<string, string>, preserveLayoutCache?: boolean): void;
|
|
55
|
+
invalidateLayoutEntries(entryIds: readonly string[]): void;
|
|
39
56
|
render(width: number): string[];
|
|
40
57
|
handleMouse(event: MouseEvent): void;
|
|
41
58
|
handleInput(keyData: string): void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { ImageContent } from "@gajae-code/ai";
|
|
2
2
|
import type { CustomMessage } from "../session/messages";
|
|
3
|
+
import { type GhResult, type RunGh, runGhDefault } from "../utils/gh";
|
|
4
|
+
export type { GhResult, RunGh };
|
|
5
|
+
export { runGhDefault };
|
|
3
6
|
export declare const STAR_REMINDER_REPO = "Yeachan-Heo/gajae-code";
|
|
4
7
|
export declare const STAR_REMINDER_CUSTOM_TYPE = "star-reminder";
|
|
5
8
|
export declare const STARRED_CACHE_TTL_MS: number;
|
|
@@ -10,15 +13,6 @@ export interface StarReminderState {
|
|
|
10
13
|
starredCheckedAt: string;
|
|
11
14
|
}
|
|
12
15
|
export type StarCheckStatus = "starred" | "unstarred" | "unavailable";
|
|
13
|
-
export interface GhResult {
|
|
14
|
-
exitCode: number;
|
|
15
|
-
stdout: string;
|
|
16
|
-
stderr: string;
|
|
17
|
-
timedOut?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export type RunGh = (args: string[], options?: {
|
|
20
|
-
timeoutMs?: number;
|
|
21
|
-
}) => Promise<GhResult>;
|
|
22
16
|
export interface StarReminderDeps {
|
|
23
17
|
statePath?: string;
|
|
24
18
|
now?: () => Date;
|
|
@@ -49,10 +43,6 @@ export declare function recordStarredFromPut(deps?: StarReminderDeps): Promise<S
|
|
|
49
43
|
export declare function recordFreshStarCheck(status: "starred" | "unstarred", deps?: StarReminderDeps): Promise<StarReminderState>;
|
|
50
44
|
/** Record a launch-nudge decline. Never downgrades a confirmed star. */
|
|
51
45
|
export declare function recordDeclinedAfterNo(deps?: StarReminderDeps): Promise<StarReminderState>;
|
|
52
|
-
/** Default `gh` runner. Returns an unavailable-style result instead of throwing. */
|
|
53
|
-
export declare function runGhDefault(args: string[], options?: {
|
|
54
|
-
timeoutMs?: number;
|
|
55
|
-
}): Promise<GhResult>;
|
|
56
46
|
/** Classify the star state of the repo via `gh api`. */
|
|
57
47
|
export declare function checkGhStarred(deps?: StarReminderDeps): Promise<StarCheckStatus>;
|
|
58
48
|
/** Star the repo via `gh api -X PUT`. Returns whether the PUT succeeded. */
|
|
@@ -6,6 +6,7 @@ import type { MCPToolDetails } from "./tool-bridge";
|
|
|
6
6
|
import type { MCPToolCache } from "./tool-cache";
|
|
7
7
|
import type { MCPGetPromptResult, MCPPrompt, MCPRequestOptions, MCPResource, MCPResourceReadResult, MCPResourceTemplate, MCPServerConfig, MCPServerConnection } from "./types";
|
|
8
8
|
export declare function resolveStartupTimeoutMs(configs: MCPServerConfig[], maxStartupTimeoutMs?: number): number;
|
|
9
|
+
export declare function resolveExactConfigStartupTimeoutMs(configs: MCPServerConfig[]): number;
|
|
9
10
|
/**
|
|
10
11
|
* Stable, total ordering on MCP tools by name.
|
|
11
12
|
*
|
|
@@ -2,7 +2,9 @@ import { SdkClient, SdkClientError, type SdkFrame } from "../client";
|
|
|
2
2
|
type JsonObject = Record<string, unknown>;
|
|
3
3
|
/** The small agent-side ACP surface used for reverse requests. */
|
|
4
4
|
export interface AcpReverseConnection {
|
|
5
|
-
request?(method: string, params: JsonObject
|
|
5
|
+
request?(method: string, params: JsonObject, options?: {
|
|
6
|
+
cancellationSignal?: AbortSignal;
|
|
7
|
+
}): Promise<unknown>;
|
|
6
8
|
[key: string]: unknown;
|
|
7
9
|
}
|
|
8
10
|
export interface AcpProviderRegistration {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Broker } from "./broker";
|
|
2
|
+
export type BrokerShutdownSendAction = "dropped" | "wait_for_drain" | "close";
|
|
3
|
+
export declare function brokerShutdownSendAction(status: number): BrokerShutdownSendAction;
|
|
2
4
|
/** Loopback-only WebSocket transport for the agent-global SDK broker. */
|
|
3
5
|
export declare class BrokerTransport {
|
|
4
6
|
#private;
|
|
@@ -16,7 +16,10 @@ export type ChatDaemonAction = "stop" | "reload";
|
|
|
16
16
|
* when deleting an observed owner-lock lease. Generation 12 refreshes retained
|
|
17
17
|
* native path and process authority semantics. Generation 13 rejects special
|
|
18
18
|
* files before retained native authority opens. Generation 14 reloads shared
|
|
19
|
-
* chat daemons after notification configuration parsing changes.
|
|
19
|
+
* chat daemons after notification configuration parsing changes. Generation 15
|
|
20
|
+
* applies the current notification configuration directly when starting chat
|
|
21
|
+
* daemon transports. Generation 16 applies Telegram sound-policy configuration
|
|
22
|
+
* through shared notification parsing.
|
|
20
23
|
*/
|
|
21
24
|
export declare const CHAT_DAEMON_GENERATIONS: Readonly<Record<ChatDaemonKind, number>>;
|
|
22
25
|
export declare function chatDaemonGeneration(kind: ChatDaemonKind): number;
|
|
@@ -28,6 +28,7 @@ export interface NotificationSettingsSnapshot {
|
|
|
28
28
|
botToken?: string;
|
|
29
29
|
chatId?: string;
|
|
30
30
|
activation?: Record<string, unknown>;
|
|
31
|
+
sound: "all" | "important" | "none";
|
|
31
32
|
btw: {
|
|
32
33
|
enabled: boolean;
|
|
33
34
|
};
|
|
@@ -105,6 +106,7 @@ export interface NotificationConfig {
|
|
|
105
106
|
* (those carrying {@link SPAWN_PROVENANCE_ENV}) unless they explicitly opt in.
|
|
106
107
|
*/
|
|
107
108
|
sessionScope: "all" | "primary";
|
|
109
|
+
sound: "all" | "important" | "none";
|
|
108
110
|
idleTimeoutMs: number;
|
|
109
111
|
btw: {
|
|
110
112
|
enabled: boolean;
|
|
@@ -177,7 +179,7 @@ export declare function isTelegramConfigured(cfg: NotificationConfig): cfg is No
|
|
|
177
179
|
chatId: string;
|
|
178
180
|
};
|
|
179
181
|
/** Is Discord configured with all credentials and routing identifiers required by its daemon. */
|
|
180
|
-
export declare function isDiscordConfigured(cfg: NotificationConfig): cfg is NotificationConfig & {
|
|
182
|
+
export declare function isDiscordConfigured(cfg: Pick<NotificationConfig, "enabled" | "discord">): cfg is Pick<NotificationConfig, "enabled"> & {
|
|
181
183
|
discord: {
|
|
182
184
|
botToken: string;
|
|
183
185
|
applicationId: string;
|
|
@@ -186,7 +188,7 @@ export declare function isDiscordConfigured(cfg: NotificationConfig): cfg is Not
|
|
|
186
188
|
};
|
|
187
189
|
};
|
|
188
190
|
/** Is Slack configured with both SDK tokens and its workspace/channel routing identifiers. */
|
|
189
|
-
export declare function isSlackConfigured(cfg: NotificationConfig): cfg is NotificationConfig & {
|
|
191
|
+
export declare function isSlackConfigured(cfg: Pick<NotificationConfig, "enabled" | "slack">): cfg is Pick<NotificationConfig, "enabled"> & {
|
|
190
192
|
slack: {
|
|
191
193
|
botToken: string;
|
|
192
194
|
appToken: string;
|
|
@@ -286,6 +288,8 @@ export interface RedactableAction {
|
|
|
286
288
|
workflowGateId?: string;
|
|
287
289
|
question?: string;
|
|
288
290
|
options?: string[];
|
|
291
|
+
/** Selected zero-based option positions for transport-specific multi-select rendering. */
|
|
292
|
+
selectedOptionIndices?: number[];
|
|
289
293
|
summary?: string;
|
|
290
294
|
/** Optional zero-based recommendation into the authoritative raw options. */
|
|
291
295
|
recommendedIndex?: number;
|
|
@@ -26,6 +26,7 @@ import type { AgentSessionEvent } from "../../session/agent-session";
|
|
|
26
26
|
import type { AskAnswerSourceResult, AskRemoteControl } from "../../tools";
|
|
27
27
|
import { SessionSdkHost } from "../host";
|
|
28
28
|
import { CursorRegistry, RevisionStore } from "../host/query";
|
|
29
|
+
import { type SdkPromptTerminalOutcome } from "../prompt-status";
|
|
29
30
|
import { type SdkStartupFailure } from "../startup-capability";
|
|
30
31
|
import { type NotificationConfig } from "./config";
|
|
31
32
|
import { NotificationSessionController } from "./session-control";
|
|
@@ -348,6 +349,23 @@ interface SessionRuntime {
|
|
|
348
349
|
commandId: string;
|
|
349
350
|
turnId: string;
|
|
350
351
|
};
|
|
352
|
+
/** Binds the executing Agent run to a correlated prompt so cleanup targets only it. */
|
|
353
|
+
bindPromptExecutionHandle: (correlation: {
|
|
354
|
+
commandId: string;
|
|
355
|
+
turnId: string;
|
|
356
|
+
}, handle: string | undefined) => void;
|
|
357
|
+
/** Reads the durable non-terminal claim for a correlated prompt, if any. */
|
|
358
|
+
peekPromptPendingOutcome: (correlation: {
|
|
359
|
+
commandId: string;
|
|
360
|
+
turnId: string;
|
|
361
|
+
}) => SdkPromptTerminalOutcome | undefined;
|
|
362
|
+
/** Claims, fences, finalizes, and publishes exactly one normalized prompt terminal. */
|
|
363
|
+
terminalizePrompt: (correlation: {
|
|
364
|
+
commandId: string;
|
|
365
|
+
turnId: string;
|
|
366
|
+
}, outcome: SdkPromptTerminalOutcome, extra?: {
|
|
367
|
+
finalText?: string;
|
|
368
|
+
}) => Promise<void>;
|
|
351
369
|
/** Records a correlated prompt terminal boundary after agent unwind. */
|
|
352
370
|
/** Atomically claims a correlated prompt terminal boundary after agent unwind. */
|
|
353
371
|
recordPromptTerminal: (correlation: {
|
|
@@ -379,6 +397,7 @@ interface SessionRuntime {
|
|
|
379
397
|
commandId?: string;
|
|
380
398
|
turnId?: string;
|
|
381
399
|
finalText?: string;
|
|
400
|
+
outcome?: SdkPromptTerminalOutcome;
|
|
382
401
|
} | {
|
|
383
402
|
type: "agent_failed";
|
|
384
403
|
sessionId: string;
|
|
@@ -388,6 +407,7 @@ interface SessionRuntime {
|
|
|
388
407
|
code: string;
|
|
389
408
|
message: string;
|
|
390
409
|
};
|
|
410
|
+
outcome?: SdkPromptTerminalOutcome;
|
|
391
411
|
}) => void;
|
|
392
412
|
/** Publishes one canonical agent-wire event to the client that owns the active prompt. */
|
|
393
413
|
emitPromptEvent: (event: AgentSessionEvent) => void;
|
|
@@ -446,6 +466,15 @@ type SessionStartResult = {
|
|
|
446
466
|
failure?: SdkStartupFailure;
|
|
447
467
|
suppressExtensionError?: boolean;
|
|
448
468
|
};
|
|
469
|
+
/**
|
|
470
|
+
* Whether the notifications control channel is enabled.
|
|
471
|
+
*
|
|
472
|
+
* Trusted sources only: enabling it opens the session control/answer channel, so
|
|
473
|
+
* a repository must not be able to turn it on. `$env` merges the caller's
|
|
474
|
+
* `cwd/.env` into `process.env`; the sibling resolvers in `config.ts` and
|
|
475
|
+
* `session-control.ts` already read an injected env record rather than the merged
|
|
476
|
+
* view, and this direct read was the outlier.
|
|
477
|
+
*/
|
|
449
478
|
export declare function notificationsEnabled(): boolean;
|
|
450
479
|
/** Workflow-gate answer shape. */
|
|
451
480
|
interface GateAnswer {
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Kind-aware invocation reconciliation (prompt | skill) with optional durable store.
|
|
3
3
|
* Preserves Q26 admit/first-terminal/capacity/TTL semantics; indexes and caps are per-kind.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import type { PromptReconciliationStatus, SdkPromptTerminalOutcome, TurnPromptReconciliation } from "../prompt-status";
|
|
6
|
+
import { type PromptCorrelation } from "./prompt-reconciliation";
|
|
6
7
|
import type { ReconciliationKind, ReconciliationStore } from "./reconciliation-store";
|
|
7
8
|
export type { ReconciliationKind };
|
|
8
9
|
export interface KindCorrelation extends PromptCorrelation {
|
|
@@ -20,6 +21,12 @@ export interface KindAwareReconciliation {
|
|
|
20
21
|
type: "agent_failed";
|
|
21
22
|
error: unknown;
|
|
22
23
|
}): Promise<void>;
|
|
24
|
+
claimPendingOutcome(correlation: PromptCorrelation, outcome: SdkPromptTerminalOutcome): Promise<SdkPromptTerminalOutcome>;
|
|
25
|
+
finalizePromptOutcome(correlation: PromptCorrelation, outcome?: SdkPromptTerminalOutcome, recordError?: {
|
|
26
|
+
code: string;
|
|
27
|
+
message: string;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
peekPendingOutcome(correlation: PromptCorrelation): SdkPromptTerminalOutcome | undefined;
|
|
23
30
|
lookup(kind: ReconciliationKind, selector: {
|
|
24
31
|
commandId?: string;
|
|
25
32
|
turnId?: string;
|
|
@@ -48,6 +48,8 @@ export declare function buildCreateArgv(frame: SessionCreateFrame, _ids: {
|
|
|
48
48
|
/** Real daemon-safe tmux launcher: canonical owner-isolation plan + GJC tags. */
|
|
49
49
|
export declare function daemonSpawnCreate(env?: NodeJS.ProcessEnv, opts?: {
|
|
50
50
|
ownerIsolationProbe?: OwnerIsolationProbe;
|
|
51
|
+
platform?: NodeJS.Platform;
|
|
52
|
+
processIncarnation?: (pid: number) => string | undefined;
|
|
51
53
|
}): (frame: SessionCreateFrame, ids: {
|
|
52
54
|
lifecycleRequestId: string;
|
|
53
55
|
intendedSessionId: string;
|
|
@@ -73,6 +75,8 @@ export declare function daemonResumeSession(env?: NodeJS.ProcessEnv, opts?: {
|
|
|
73
75
|
sessionsRoot?: string;
|
|
74
76
|
listSessions?: (env: NodeJS.ProcessEnv) => GjcTmuxSessionStatus[];
|
|
75
77
|
ownerIsolationProbe?: OwnerIsolationProbe;
|
|
78
|
+
platform?: NodeJS.Platform;
|
|
79
|
+
processIncarnation?: (pid: number) => string | undefined;
|
|
76
80
|
}): (target: {
|
|
77
81
|
sessionIdOrPrefix: string;
|
|
78
82
|
path?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PromptReconciliationStatus, SdkPromptTerminalOutcome } from "../prompt-status";
|
|
2
|
+
import type { PromptCorrelation } from "./prompt-reconciliation";
|
|
2
3
|
export declare const RECONCILIATION_STORE_VERSION = 1;
|
|
3
4
|
export declare const RECONCILIATION_SESSION_ID_PATTERN: RegExp;
|
|
4
5
|
export declare const RECONCILIATION_DIR_NAME = ".sdk-reconciliation";
|
|
@@ -14,6 +15,8 @@ export interface DurableReconciliationRecord extends PromptCorrelation {
|
|
|
14
15
|
acceptedAt: number;
|
|
15
16
|
startedAt?: number;
|
|
16
17
|
terminalAt?: number;
|
|
18
|
+
outcome?: SdkPromptTerminalOutcome;
|
|
19
|
+
pendingOutcome?: SdkPromptTerminalOutcome;
|
|
17
20
|
/** Skill-only safe token; never skill args bodies. */
|
|
18
21
|
skillName?: string;
|
|
19
22
|
}
|
|
@@ -43,8 +46,9 @@ export declare function isSafeReconciliationSessionId(sessionId: string): boolea
|
|
|
43
46
|
/** Derive private store path; throws if sessionId is unsafe (path escape). */
|
|
44
47
|
export declare function reconciliationStorePath(sessionFile: string, sessionId: string): string;
|
|
45
48
|
/**
|
|
46
|
-
* Settle non-terminal durable records after process death
|
|
47
|
-
*
|
|
49
|
+
* Settle non-terminal durable records after process death.
|
|
50
|
+
* Prompt records preserve a durable pending outcome; skills retain the existing
|
|
51
|
+
* reconciliation-incomplete result.
|
|
48
52
|
*/
|
|
49
53
|
export declare function settleProcessRestart(records: DurableReconciliationRecord[], now: number): DurableReconciliationRecord[];
|
|
50
54
|
export interface ReconciliationStore {
|
|
@@ -63,6 +63,7 @@ export declare class DraftStreamState {
|
|
|
63
63
|
export declare function deliverDraft(botApi: BotApi, base: {
|
|
64
64
|
chat_id: string | number;
|
|
65
65
|
message_thread_id?: number;
|
|
66
|
+
disable_notification?: true;
|
|
66
67
|
}, draftId: number, raw: string, log?: {
|
|
67
68
|
warn(msg: string): void;
|
|
68
69
|
}): Promise<void>;
|
|
@@ -43,6 +43,7 @@ export declare function shouldPromoteRich(input: {
|
|
|
43
43
|
export declare function deliverRichWithFallback(botApi: BotApi, base: {
|
|
44
44
|
chat_id: string | number;
|
|
45
45
|
message_thread_id?: number;
|
|
46
|
+
disable_notification?: true;
|
|
46
47
|
}, send: ThreadedSend, signal: AbortSignal, fallbackDeliver: () => Promise<void>, log?: {
|
|
47
48
|
warn(msg: string): void;
|
|
48
49
|
}): Promise<number | undefined>;
|
|
@@ -55,6 +56,7 @@ export declare function deliverRichWithFallback(botApi: BotApi, base: {
|
|
|
55
56
|
export declare function deliverRichActionWithFallback(botApi: BotApi, base: {
|
|
56
57
|
chat_id: string | number;
|
|
57
58
|
message_thread_id?: number;
|
|
59
|
+
disable_notification?: true;
|
|
58
60
|
}, opts: {
|
|
59
61
|
markdown: string;
|
|
60
62
|
replyMarkup?: unknown;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable, non-routable sidecar store for "adopt a user-created Telegram forum
|
|
3
|
+
* topic into a preallocated session" intents.
|
|
4
|
+
*
|
|
5
|
+
* When a user creates a new forum topic, the daemon first records durable
|
|
6
|
+
* pending-topic authorization. After folder selection it preallocates an
|
|
7
|
+
* `intendedSessionId` and records an adoption intent here *before* spawning.
|
|
8
|
+
* Later, the authenticated `ensureTopic` create callback reads that intent and
|
|
9
|
+
* returns the user's existing topicId to `TopicRegistry.getOrCreateTopic`, which
|
|
10
|
+
* is the only authority that commits a topic binding. This keeps the intent out
|
|
11
|
+
* of routing/endpoint authority until commit, so a failed spawn or a late socket
|
|
12
|
+
* never deletes the user's topic and never strands a duplicate.
|
|
13
|
+
*
|
|
14
|
+
* Invariants (see `pending-approval.md`):
|
|
15
|
+
* - One file per intent, named `<intendedSessionId>.adoption-intent.json` under
|
|
16
|
+
* the daemon notifications dir. Sweep touches files only; never the Telegram API.
|
|
17
|
+
* - Only `{ intendedSessionId, topicId, chatId, target, createdAt, expiresAt }`
|
|
18
|
+
* is persisted. Bot/control tokens and endpoint digests are never stored.
|
|
19
|
+
* - Owner-only dir (0o700) and 0o600 files; atomic temp→fsync→chmod→rename→parent sync.
|
|
20
|
+
* - `tryClaim` is a synchronous, in-memory claim keyed by topicId; it excludes a
|
|
21
|
+
* second `intendedSessionId` from winning the same topic across awaits. It
|
|
22
|
+
* does not delete the sidecar; `releaseClaim` re-enables retry on commit failure.
|
|
23
|
+
*/
|
|
24
|
+
import type { SessionCreateTarget } from "./index";
|
|
25
|
+
/** Persisted document version. */
|
|
26
|
+
export declare const TELEGRAM_ADOPTION_INTENT_VERSION = 1;
|
|
27
|
+
export type TelegramAdoptionTarget = Extract<SessionCreateTarget, {
|
|
28
|
+
kind: "existing_path";
|
|
29
|
+
}>;
|
|
30
|
+
/** Default intent TTL (configurable at write time). Plan starts at 10 minutes. */
|
|
31
|
+
export declare const DEFAULT_ADOPTION_INTENT_TTL_MS: number;
|
|
32
|
+
/**
|
|
33
|
+
* Minimal async filesystem surface the store needs. Structurally a subset of the
|
|
34
|
+
* daemon's `TelegramDaemonFs` / `ConversationStoreFs`, so the daemon can pass its
|
|
35
|
+
* own `fs` straight through and tests can inject a fake. `open`/`sync`/`close`
|
|
36
|
+
* mirror `ConversationStoreFileHandle` so the atomic fsync path reuses the same
|
|
37
|
+
* shape as the conversation store.
|
|
38
|
+
*/
|
|
39
|
+
export interface AdoptionIntentFs {
|
|
40
|
+
mkdir(directory: string, options: {
|
|
41
|
+
recursive: true;
|
|
42
|
+
mode: number;
|
|
43
|
+
}): Promise<unknown>;
|
|
44
|
+
chmod(target: string, mode: number): Promise<void>;
|
|
45
|
+
readFile(file: string, encoding: "utf8"): Promise<string>;
|
|
46
|
+
writeFile(file: string, data: string, options: {
|
|
47
|
+
mode: number;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
rename(from: string, to: string): Promise<void>;
|
|
50
|
+
unlink(file: string): Promise<unknown>;
|
|
51
|
+
readdir(directory: string): Promise<readonly string[]>;
|
|
52
|
+
open(file: string, flags: string): Promise<AdoptionIntentFileHandle>;
|
|
53
|
+
}
|
|
54
|
+
export interface AdoptionIntentFileHandle {
|
|
55
|
+
sync(): Promise<void>;
|
|
56
|
+
close(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/** What gets persisted per intent. No tokens, no digests. */
|
|
59
|
+
export interface TelegramAdoptionIntent {
|
|
60
|
+
intendedSessionId: string;
|
|
61
|
+
topicId: number;
|
|
62
|
+
chatId: string;
|
|
63
|
+
target: TelegramAdoptionTarget;
|
|
64
|
+
createdAt: number;
|
|
65
|
+
expiresAt: number;
|
|
66
|
+
}
|
|
67
|
+
/** Durable authorization that a topic was observed through forum_topic_created. */
|
|
68
|
+
export interface TelegramPendingTopic {
|
|
69
|
+
topicId: number;
|
|
70
|
+
chatId: string;
|
|
71
|
+
createdAt: number;
|
|
72
|
+
expiresAt: number;
|
|
73
|
+
}
|
|
74
|
+
/** Compose the per-intent sidecar path. Public so callers/tests can inspect it. */
|
|
75
|
+
export declare function adoptionIntentFilePath(agentDir: string, intendedSessionId: string): string;
|
|
76
|
+
/** Compose the sidecar path for a user-created topic awaiting a folder choice. */
|
|
77
|
+
export declare function pendingTopicFilePath(agentDir: string, topicId: number): string;
|
|
78
|
+
/** Build a fresh intent with `createdAt`/`expiresAt` derived from `now`/`ttlMs`. */
|
|
79
|
+
export declare function buildAdoptionIntent(input: {
|
|
80
|
+
intendedSessionId: string;
|
|
81
|
+
topicId: number;
|
|
82
|
+
chatId: string;
|
|
83
|
+
target: TelegramAdoptionTarget;
|
|
84
|
+
now?: number;
|
|
85
|
+
ttlMs?: number;
|
|
86
|
+
}): TelegramAdoptionIntent;
|
|
87
|
+
/** Test-only: filename suffix used to recognize intent sidecars in a directory listing. */
|
|
88
|
+
export declare const ADOPTION_INTENT_FILENAME_SUFFIX = ".adoption-intent.json";
|
|
89
|
+
export declare const PENDING_TOPIC_FILENAME_SUFFIX = ".pending-topic.json";
|
|
90
|
+
/**
|
|
91
|
+
* Durable, non-routable adoption-intent store. Owns durable sidecar files and
|
|
92
|
+
* the synchronous in-memory topicId claim table. The daemon owns Telegram and
|
|
93
|
+
* lifecycle wiring; this store never calls the Telegram API.
|
|
94
|
+
*/
|
|
95
|
+
export declare class TelegramAdoptionIntentStore {
|
|
96
|
+
#private;
|
|
97
|
+
constructor(input: {
|
|
98
|
+
agentDir: string;
|
|
99
|
+
fs?: AdoptionIntentFs;
|
|
100
|
+
now?: () => number;
|
|
101
|
+
platform?: NodeJS.Platform;
|
|
102
|
+
});
|
|
103
|
+
/** Directory holding the sidecar files. */
|
|
104
|
+
get directory(): string;
|
|
105
|
+
/** In-memory lookup by intendedSessionId (no disk read). undefined if absent/expired. */
|
|
106
|
+
bySession(intendedSessionId: string): TelegramAdoptionIntent | undefined;
|
|
107
|
+
/** In-memory lookup of the (single) non-expired intent for a topicId. */
|
|
108
|
+
byTopic(topicId: number): TelegramAdoptionIntent | undefined;
|
|
109
|
+
/** `true` if a non-expired intent already references `topicId`. */
|
|
110
|
+
hasNonExpiredTopic(topicId: number): boolean;
|
|
111
|
+
/** Durable authorization for an observed user-created topic, if still live. */
|
|
112
|
+
pendingTopic(topicId: number): TelegramPendingTopic | undefined;
|
|
113
|
+
hasPendingTopic(topicId: number, chatId: string): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Synchronously claim `topicId` for `intendedSessionId`. Returns false if a
|
|
116
|
+
* *different* non-expired intendedSessionId already holds the claim (or has a
|
|
117
|
+
* non-expired intent for the topic). Same intendedSessionId re-claiming its
|
|
118
|
+
* own topic is idempotent and succeeds. The claim is in-memory only; it never
|
|
119
|
+
* deletes the sidecar, so a commit failure can `releaseClaim` and retry.
|
|
120
|
+
*/
|
|
121
|
+
tryClaim(topicId: number, intendedSessionId: string): boolean;
|
|
122
|
+
/** Release a claim held by `intendedSessionId` on `topicId`. No-op otherwise. */
|
|
123
|
+
releaseClaim(topicId: number, intendedSessionId: string): void;
|
|
124
|
+
/**
|
|
125
|
+
* Durable write of one intent: temp→write→fsync→chmod(0600)→atomic rename→
|
|
126
|
+
* chmod(final, 0600)→parent-dir fsync, then track it in memory. The dir is
|
|
127
|
+
* created owner-only (0700). chmod-ing the final path after the rename makes
|
|
128
|
+
* the 0600 contract durable regardless of whether the platform's rename
|
|
129
|
+
* preserves the source mode (POSIX does; some test/network filesystems and
|
|
130
|
+
* the in-memory test double model rename as copy+delete and would otherwise
|
|
131
|
+
* drop it). The rename is still the atomic commit point; the final chmod only
|
|
132
|
+
* tightens permissions on the already-durable file. The in-memory map is only
|
|
133
|
+
* mutated after the atomic persist succeeds. Rejects (does not swallow) so the
|
|
134
|
+
* daemon can decide fail-closed behavior.
|
|
135
|
+
*/
|
|
136
|
+
put(intent: TelegramAdoptionIntent): Promise<void>;
|
|
137
|
+
/** Persist authorization for a topic observed through forum_topic_created. */
|
|
138
|
+
putPendingTopic(pendingTopic: TelegramPendingTopic): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Read a single intent sidecar from disk and track it if it is non-expired
|
|
141
|
+
* and well-formed. Returns the parsed intent (or undefined). Used by
|
|
142
|
+
* `rehydrate`; callers normally use `rehydrate` / `bySession`.
|
|
143
|
+
*/
|
|
144
|
+
readIntent(intendedSessionId: string): Promise<TelegramAdoptionIntent | undefined>;
|
|
145
|
+
readPendingTopic(topicId: number): Promise<TelegramPendingTopic | undefined>;
|
|
146
|
+
/**
|
|
147
|
+
* Rehydrate all non-expired intents from the notifications dir. Files are the
|
|
148
|
+
* only source: missing/corrupt/expired entries are skipped (never thrown).
|
|
149
|
+
* Returns the count of live intents loaded.
|
|
150
|
+
*/
|
|
151
|
+
rehydrate(): Promise<number>;
|
|
152
|
+
/**
|
|
153
|
+
* Remove a single intent sidecar and drop its in-memory entry. Safe to call
|
|
154
|
+
* after a successful registry commit or a definite spawn failure. Missing
|
|
155
|
+
* files are not an error. Never calls the Telegram API.
|
|
156
|
+
*/
|
|
157
|
+
remove(intendedSessionId: string): Promise<void>;
|
|
158
|
+
/** Remove a pending-topic authorization after an adoption intent is durable. */
|
|
159
|
+
removePendingTopic(topicId: number): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Sweep expired intent sidecars from disk. Touches files only. Returns the
|
|
162
|
+
* count of expired sidecars removed. Safe to run at startup and periodically.
|
|
163
|
+
*/
|
|
164
|
+
sweepExpired(): Promise<number>;
|
|
165
|
+
}
|
|
@@ -16,4 +16,16 @@
|
|
|
16
16
|
* If neither --endpoint-file nor --session-id is given, the newest endpoint file
|
|
17
17
|
* under <repo>/.gjc/state/sdk/ is used.
|
|
18
18
|
*/
|
|
19
|
+
import { type TelegramNotificationSound } from "./telegram-reference";
|
|
20
|
+
interface CliArgs {
|
|
21
|
+
botToken?: string;
|
|
22
|
+
chatId?: string;
|
|
23
|
+
endpointFile?: string;
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
repo: string;
|
|
26
|
+
apiBase?: string;
|
|
27
|
+
sound: TelegramNotificationSound;
|
|
28
|
+
force: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function parseArgs(argv: string[]): CliArgs;
|
|
19
31
|
export {};
|
|
@@ -38,12 +38,19 @@ export declare const NOTIFICATION_PROTOCOL_VERSION = 3;
|
|
|
38
38
|
* Generation 29 adds serving-epoch compatibility, sidecar heartbeat, root GC,
|
|
39
39
|
* and Bot API cooldown structural fixes (#2956, #2960, #3048).
|
|
40
40
|
* Generation 30 adds opt-in tool activity delivery, closed lifecycle phases,
|
|
41
|
-
* and capability-versioned mixed-host compatibility.
|
|
41
|
+
* and capability-versioned mixed-host compatibility. Generation 31 rolls out
|
|
42
|
+
* non-Linux direct tmux lifecycle cleanup semantics. Generation 32 applies
|
|
43
|
+
* Telegram sound-notification policy across daemon delivery paths. Generation
|
|
44
|
+
* 33 adds action-bound multi-select state rendering and replay-safe option
|
|
45
|
+
* snapshots. Generation 34 converts non-photo image formats (including WebP)
|
|
46
|
+
* into Telegram-compatible photo uploads when possible. Generation 35 adds
|
|
47
|
+
* user-created topic adoption (forum-topic folder picker).
|
|
42
48
|
*/
|
|
43
|
-
export declare const DAEMON_GENERATION =
|
|
49
|
+
export declare const DAEMON_GENERATION = 35;
|
|
44
50
|
/**
|
|
45
51
|
* Serving-compatibility boundary for daemon lifecycle requests. Epoch 1 covers
|
|
46
52
|
* all builds published before this field existed; epoch 2 covered generation 29;
|
|
47
|
-
* bump this to force serving convergence and
|
|
53
|
+
* epoch 3 covered generation 30; bump this to force serving convergence and
|
|
54
|
+
* reload of compatible live predecessors.
|
|
48
55
|
*/
|
|
49
|
-
export declare const SERVING_EPOCH =
|
|
56
|
+
export declare const SERVING_EPOCH = 4;
|