flavor-code 1.2.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.
Files changed (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1081 -0
  3. package/dist/agent/loop.d.ts +31 -0
  4. package/dist/agent/message-queue.d.ts +19 -0
  5. package/dist/agent/planner.d.ts +28 -0
  6. package/dist/agent/subagents.d.ts +50 -0
  7. package/dist/agent/task-plan.d.ts +60 -0
  8. package/dist/agent/task-tools.d.ts +11 -0
  9. package/dist/agent/types.d.ts +117 -0
  10. package/dist/app-WC2XXGLM.js +3185 -0
  11. package/dist/app-WC2XXGLM.js.map +1 -0
  12. package/dist/auth/oauth-config.d.ts +4 -0
  13. package/dist/auth/oauth.d.ts +21 -0
  14. package/dist/auth/store.d.ts +15 -0
  15. package/dist/auth/types.d.ts +33 -0
  16. package/dist/chunk-BU64GNXE.js +15771 -0
  17. package/dist/chunk-BU64GNXE.js.map +1 -0
  18. package/dist/chunk-DM64TM4Z.js +124 -0
  19. package/dist/chunk-DM64TM4Z.js.map +1 -0
  20. package/dist/chunk-JZ322RCJ.js +40 -0
  21. package/dist/chunk-JZ322RCJ.js.map +1 -0
  22. package/dist/chunk-M744K7MK.js +246 -0
  23. package/dist/chunk-M744K7MK.js.map +1 -0
  24. package/dist/chunk-MVIMQEQT.js +692 -0
  25. package/dist/chunk-MVIMQEQT.js.map +1 -0
  26. package/dist/chunk-VOCZVFP7.js +153 -0
  27. package/dist/chunk-VOCZVFP7.js.map +1 -0
  28. package/dist/chunk-XS2JU6S3.js +35557 -0
  29. package/dist/chunk-XS2JU6S3.js.map +1 -0
  30. package/dist/claude-ink-ZL4UZMFY.js +27 -0
  31. package/dist/claude-ink-ZL4UZMFY.js.map +1 -0
  32. package/dist/cli.js +915 -0
  33. package/dist/cli.js.map +1 -0
  34. package/dist/codeisland/activate.mjs +74 -0
  35. package/dist/codeisland/bridge.mjs +97 -0
  36. package/dist/codeisland/flavor-plugin.json +27 -0
  37. package/dist/config/load.d.ts +19 -0
  38. package/dist/config/protected-file.d.ts +15 -0
  39. package/dist/config/schema.d.ts +176 -0
  40. package/dist/config/secret-envelope.d.ts +8 -0
  41. package/dist/context/compaction.d.ts +44 -0
  42. package/dist/context/manager.d.ts +65 -0
  43. package/dist/context/summarizer.d.ts +15 -0
  44. package/dist/desktop/main.js +17778 -0
  45. package/dist/desktop/main.js.map +1 -0
  46. package/dist/desktop/preload.cjs +90 -0
  47. package/dist/desktop/preload.cjs.map +1 -0
  48. package/dist/desktop-renderer/assets/index-C66pDvHs.js +144 -0
  49. package/dist/desktop-renderer/assets/index-C66pDvHs.js.map +1 -0
  50. package/dist/desktop-renderer/assets/index-Cm_ktmXm.css +1 -0
  51. package/dist/desktop-renderer/index.html +16 -0
  52. package/dist/devtools-SXJBSV2N.js +3 -0
  53. package/dist/devtools-SXJBSV2N.js.map +1 -0
  54. package/dist/execution/docker.d.ts +29 -0
  55. package/dist/execution/factory.d.ts +3 -0
  56. package/dist/execution/types.d.ts +18 -0
  57. package/dist/goal/classifier.d.ts +12 -0
  58. package/dist/goal/orchestrator.d.ts +34 -0
  59. package/dist/goal/planner.d.ts +9 -0
  60. package/dist/goal/store.d.ts +9 -0
  61. package/dist/goal/types.d.ts +190 -0
  62. package/dist/hallucination/confidence.d.ts +12 -0
  63. package/dist/hallucination/evidence-ledger.d.ts +29 -0
  64. package/dist/hallucination/guard.d.ts +27 -0
  65. package/dist/hallucination/messages.d.ts +10 -0
  66. package/dist/hallucination/retry-monitor.d.ts +19 -0
  67. package/dist/hallucination/sliding-window.d.ts +13 -0
  68. package/dist/hallucination/types.d.ts +49 -0
  69. package/dist/harness/local.d.ts +54 -0
  70. package/dist/hooks/bus.d.ts +9 -0
  71. package/dist/hooks/types.d.ts +105 -0
  72. package/dist/ide/client.d.ts +35 -0
  73. package/dist/incidents/reporter.d.ts +38 -0
  74. package/dist/init/project.d.ts +25 -0
  75. package/dist/load-WQGNTCHC.js +20 -0
  76. package/dist/load-WQGNTCHC.js.map +1 -0
  77. package/dist/loop/budget.d.ts +11 -0
  78. package/dist/loop/isolation.d.ts +21 -0
  79. package/dist/loop/orchestrator.d.ts +82 -0
  80. package/dist/loop/store.d.ts +13 -0
  81. package/dist/loop/types.d.ts +142 -0
  82. package/dist/loop/verifier.d.ts +13 -0
  83. package/dist/mcp/client.d.ts +66 -0
  84. package/dist/mcp/sdk.d.ts +27 -0
  85. package/dist/memory/coordinator.d.ts +32 -0
  86. package/dist/memory/extractor.d.ts +15 -0
  87. package/dist/memory/intent.d.ts +2 -0
  88. package/dist/memory/retrieval.d.ts +13 -0
  89. package/dist/memory/review.d.ts +36 -0
  90. package/dist/memory/similarity.d.ts +5 -0
  91. package/dist/memory/store.d.ts +58 -0
  92. package/dist/memory/types.d.ts +37 -0
  93. package/dist/models/anthropic.d.ts +24 -0
  94. package/dist/models/cache-profile.d.ts +23 -0
  95. package/dist/models/openai.d.ts +24 -0
  96. package/dist/models/registry.d.ts +16 -0
  97. package/dist/models/structured.d.ts +75 -0
  98. package/dist/models/types.d.ts +93 -0
  99. package/dist/permissions/classifier.d.ts +9 -0
  100. package/dist/permissions/engine.d.ts +28 -0
  101. package/dist/plugins/host.d.ts +15 -0
  102. package/dist/plugins/types.d.ts +136 -0
  103. package/dist/production.d.ts +59 -0
  104. package/dist/prompts/system.d.ts +28 -0
  105. package/dist/rpc/schema.d.ts +61 -0
  106. package/dist/rpc/server.d.ts +54 -0
  107. package/dist/sdk/index.d.ts +19 -0
  108. package/dist/sdk/index.js +53 -0
  109. package/dist/sdk/index.js.map +1 -0
  110. package/dist/session/checkpoint.d.ts +25 -0
  111. package/dist/session/store.d.ts +154 -0
  112. package/dist/session/tree.d.ts +31 -0
  113. package/dist/skills/builtin-loop.d.ts +12 -0
  114. package/dist/skills/registry.d.ts +47 -0
  115. package/dist/skills/tool.d.ts +9 -0
  116. package/dist/sleep/organizer.d.ts +37 -0
  117. package/dist/tools/ask-user-question.d.ts +49 -0
  118. package/dist/tools/file-diff.d.ts +9 -0
  119. package/dist/tools/files.d.ts +49 -0
  120. package/dist/tools/lsp.d.ts +77 -0
  121. package/dist/tools/managed.d.ts +59 -0
  122. package/dist/tools/runtime.d.ts +58 -0
  123. package/dist/tools/search.d.ts +76 -0
  124. package/dist/tools/shell.d.ts +37 -0
  125. package/dist/tools/task-output.d.ts +53 -0
  126. package/dist/tools/todo-write.d.ts +35 -0
  127. package/dist/tools/types.d.ts +56 -0
  128. package/dist/trace/recorder.d.ts +14 -0
  129. package/dist/trace/replay.d.ts +3 -0
  130. package/dist/trace/schema.d.ts +26 -0
  131. package/dist/ui/commands.d.ts +67 -0
  132. package/dist/ui/session.d.ts +126 -0
  133. package/dist/ui/transcript.d.ts +89 -0
  134. package/dist/utils/async.d.ts +5 -0
  135. package/dist/utils/envUtils.d.ts +1 -0
  136. package/dist/utils/error.d.ts +2 -0
  137. package/dist/utils/execFileNoThrow.d.ts +13 -0
  138. package/dist/utils/intl.d.ts +18 -0
  139. package/dist/utils/json.d.ts +44 -0
  140. package/dist/utils/log.d.ts +28 -0
  141. package/dist/utils/redact.d.ts +10 -0
  142. package/dist/utils/usage-summary.d.ts +34 -0
  143. package/dist/utils/version.d.ts +6 -0
  144. package/package.json +124 -0
  145. package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +4797 -0
@@ -0,0 +1,136 @@
1
+ import { z } from "zod";
2
+ import { type HookEventName, type HookHandler, type HookHandlerOptions } from "../hooks/types.js";
3
+ import type { ModelAdapter } from "../models/types.js";
4
+ import type { ToolDefinition } from "../tools/types.js";
5
+ export declare const PluginManifestSchema: z.ZodObject<{
6
+ name: z.ZodString;
7
+ version: z.ZodString;
8
+ apiVersion: z.ZodLiteral<"1">;
9
+ main: z.ZodString;
10
+ permissions: z.ZodArray<z.ZodEnum<{
11
+ "filesystem:read": "filesystem:read";
12
+ "filesystem:write": "filesystem:write";
13
+ }>>;
14
+ contributes: z.ZodObject<{
15
+ commands: z.ZodArray<z.ZodObject<{
16
+ name: z.ZodString;
17
+ }, z.core.$strict>>;
18
+ tools: z.ZodArray<z.ZodObject<{
19
+ name: z.ZodString;
20
+ }, z.core.$strict>>;
21
+ hooks: z.ZodArray<z.ZodObject<{
22
+ name: z.ZodEnum<{
23
+ AfterModelCall: "AfterModelCall";
24
+ AfterPlan: "AfterPlan";
25
+ BeforeModelCall: "BeforeModelCall";
26
+ BeforePlan: "BeforePlan";
27
+ Notification: "Notification";
28
+ PermissionRequest: "PermissionRequest";
29
+ PluginLoad: "PluginLoad";
30
+ PluginUnload: "PluginUnload";
31
+ PostCompact: "PostCompact";
32
+ PostToolUse: "PostToolUse";
33
+ PostToolUseFailure: "PostToolUseFailure";
34
+ PreCompact: "PreCompact";
35
+ PreToolUse: "PreToolUse";
36
+ SessionEnd: "SessionEnd";
37
+ SessionStart: "SessionStart";
38
+ Stop: "Stop";
39
+ SubagentStart: "SubagentStart";
40
+ SubagentStop: "SubagentStop";
41
+ UserPromptSubmit: "UserPromptSubmit";
42
+ }>;
43
+ }, z.core.$strict>>;
44
+ skillRoots: z.ZodArray<z.ZodObject<{
45
+ name: z.ZodString;
46
+ path: z.ZodString;
47
+ }, z.core.$strict>>;
48
+ modelAdapters: z.ZodArray<z.ZodObject<{
49
+ name: z.ZodString;
50
+ }, z.core.$strict>>;
51
+ }, z.core.$strict>;
52
+ }, z.core.$strict>;
53
+ export type PluginManifest = z.infer<typeof PluginManifestSchema>;
54
+ export type PluginSource = "global" | "project" | "npm";
55
+ export type PluginPermission = PluginManifest["permissions"][number];
56
+ export interface PluginLogger {
57
+ debug(message: string): void;
58
+ info(message: string): void;
59
+ warn(message: string): void;
60
+ error(message: string): void;
61
+ }
62
+ export interface PluginFilesystemService {
63
+ readFile(path: string, encoding?: BufferEncoding): Promise<string | Uint8Array>;
64
+ writeFile(path: string, data: string | Uint8Array): Promise<void>;
65
+ }
66
+ export interface PluginServices {
67
+ readonly filesystem: PluginFilesystemService;
68
+ }
69
+ export type PluginDisposer = () => void | Promise<void>;
70
+ export interface PluginCommandContext {
71
+ readonly workspace: string;
72
+ readonly signal: AbortSignal;
73
+ }
74
+ export type PluginCommandHandler = (args: readonly string[], context: PluginCommandContext) => unknown | Promise<unknown>;
75
+ /**
76
+ * A deliberately narrow registration surface. Plugins run in-process and are trusted in the
77
+ * MVP: this API mediates host-provided capabilities, but it is not a Node.js process sandbox.
78
+ */
79
+ export interface PluginContext {
80
+ readonly signal: AbortSignal;
81
+ readonly config: unknown;
82
+ readonly logger: PluginLogger;
83
+ readonly services: PluginServices;
84
+ registerCommand(name: string, command: PluginCommandHandler): PluginDisposer;
85
+ registerTool(name: string, tool: ToolDefinition<unknown>): PluginDisposer;
86
+ registerHook(name: HookEventName, hook: HookHandler, options?: HookHandlerOptions): PluginDisposer;
87
+ registerSkillRoot(name: string, root: string): PluginDisposer;
88
+ registerModelAdapter(name: string, adapter: ModelAdapter): PluginDisposer;
89
+ }
90
+ export interface PluginSkillRootCapability {
91
+ readonly path: string;
92
+ readonly identity: {
93
+ readonly dev: bigint;
94
+ readonly ino: bigint;
95
+ readonly mtimeNs: bigint;
96
+ readonly ctimeNs: bigint;
97
+ };
98
+ }
99
+ export interface PluginDiagnostic {
100
+ readonly plugin: string;
101
+ readonly path?: string;
102
+ readonly message: string;
103
+ }
104
+ export interface LoadedPlugin {
105
+ readonly name: string;
106
+ readonly version: string;
107
+ readonly source: PluginSource;
108
+ readonly root: string;
109
+ }
110
+ export interface PluginRegistrationCallbacks {
111
+ command(name: string, command: PluginCommandHandler): PluginDisposer;
112
+ tool(name: string, tool: ToolDefinition<unknown>): PluginDisposer;
113
+ hook(name: HookEventName, hook: HookHandler, options?: HookHandlerOptions): PluginDisposer;
114
+ /** Consumers must revalidate identity before access, or delegate reading to SkillRegistry. */
115
+ skillRoot(name: string, root: PluginSkillRootCapability): PluginDisposer;
116
+ modelAdapter(name: string, adapter: ModelAdapter): PluginDisposer;
117
+ }
118
+ export interface FilesystemAuthorizationRequest {
119
+ readonly plugin: string;
120
+ readonly operation: "read" | "write";
121
+ readonly path: string;
122
+ }
123
+ export interface PluginHostOptions {
124
+ globalPluginDirs?: readonly string[];
125
+ projectPluginDirs?: readonly string[];
126
+ npmPackages?: readonly string[];
127
+ disabledPlugins?: readonly string[];
128
+ resolveNpmPackage?: (specifier: string) => string | undefined | Promise<string | undefined>;
129
+ registrations: PluginRegistrationCallbacks;
130
+ config?: unknown;
131
+ logger?: PluginLogger;
132
+ authorizeFilesystem?: (request: FilesystemAuthorizationRequest) => boolean | Promise<boolean>;
133
+ emitLifecycle?: (type: "PluginLoad" | "PluginUnload", plugin: LoadedPlugin) => void | Promise<void>;
134
+ activationTimeoutMs?: number;
135
+ unloadTimeoutMs?: number;
136
+ }
@@ -0,0 +1,59 @@
1
+ import type { AgentEvent } from "./agent/types.js";
2
+ import { GoalOrchestrator } from "./goal/orchestrator.js";
3
+ import { type McpClientFactory } from "./mcp/client.js";
4
+ import type { PermissionRequest } from "./permissions/engine.js";
5
+ import { type PromptEnvironment } from "./prompts/system.js";
6
+ import type { ApprovalDecision } from "./tools/runtime.js";
7
+ import { type FileWriteProposal } from "./tools/files.js";
8
+ import { FlavorSession, type SessionOutput, type SessionServices } from "./ui/session.js";
9
+ import { type TranscriptState } from "./ui/transcript.js";
10
+ import { MemoryReviewBridge } from "./memory/review.js";
11
+ export interface ProductionRuntimeOptions {
12
+ workspace?: string;
13
+ home?: string;
14
+ environment?: NodeJS.ProcessEnv;
15
+ output(event: SessionOutput): void;
16
+ onApprovalChange?(): void;
17
+ /** Non-interactive callers must deny requests instead of waiting for input. */
18
+ approvalPolicy?: "prompt" | "deny";
19
+ /** Allow a protocol host to resolve tool approvals without enabling other interactive UI bridges. */
20
+ rpcToolApprovals?: boolean;
21
+ /** Optional pre-commit gate used by protocol hosts to stream a proposed text write before it reaches disk. */
22
+ beforeFileCommit?(proposal: FileWriteProposal, signal: AbortSignal): Promise<void>;
23
+ /** Resume a named session, or the latest session when true. Never resumed implicitly. */
24
+ resumeSession?: string | true;
25
+ /** Test and embedding seam for creating configured MCP clients. */
26
+ mcpClientFactory?: McpClientFactory;
27
+ }
28
+ export interface ProductionRuntime {
29
+ session: FlavorSession;
30
+ services: SessionServices;
31
+ approvals: ApprovalBridge;
32
+ memoryReviews: MemoryReviewBridge;
33
+ diagnostics: readonly string[];
34
+ sessionId: string;
35
+ restoredTranscript: TranscriptState;
36
+ dispose(): Promise<void>;
37
+ }
38
+ export interface PromptEnvironmentInput {
39
+ now?: Date;
40
+ platform?: string;
41
+ osVersion?: string;
42
+ shell?: string;
43
+ isGitRepository?: boolean | "unknown";
44
+ }
45
+ export declare function createPromptEnvironment(input?: PromptEnvironmentInput): PromptEnvironment;
46
+ export declare class ApprovalBridge {
47
+ #private;
48
+ constructor(onChange?: () => void);
49
+ get pending(): (PermissionRequest & {
50
+ id: string;
51
+ reason?: string;
52
+ }) | undefined;
53
+ request(request: PermissionRequest & {
54
+ reason?: string;
55
+ }, signal?: AbortSignal): Promise<ApprovalDecision>;
56
+ resolve(decision: ApprovalDecision): void;
57
+ }
58
+ export declare function createProductionRuntime(options: ProductionRuntimeOptions): Promise<ProductionRuntime>;
59
+ export declare function runGoalSession(orchestrator: GoalOrchestrator, goal: string, signal: AbortSignal): AsyncIterable<AgentEvent>;
@@ -0,0 +1,28 @@
1
+ import type { PermissionMode } from "../permissions/engine.js";
2
+ export type PromptAgentRole = "main" | "subagent";
3
+ export interface PromptEnvironment {
4
+ date: string;
5
+ platform: NodeJS.Platform | string;
6
+ osVersion: string;
7
+ shell: string;
8
+ isGitRepository: boolean | "unknown";
9
+ }
10
+ export interface SystemPromptOptions {
11
+ agent: PromptAgentRole;
12
+ languageInstruction?: string;
13
+ workspace: string;
14
+ toolNames: ReadonlySet<string>;
15
+ environment: PromptEnvironment;
16
+ }
17
+ export declare function buildSystemPrompt(options: SystemPromptOptions): string[];
18
+ export declare function buildCurrentDateSection(date: string): string;
19
+ /**
20
+ * Volatile runtime values that change with /model or /permission commands.
21
+ * Kept out of the stable system prefix so those switches do not invalidate
22
+ * the prompt-cache prefix.
23
+ */
24
+ export declare function buildRuntimeEnvironmentSection(options: {
25
+ model: string;
26
+ permissionMode: PermissionMode;
27
+ }): string;
28
+ export declare function buildSubagentDirective(): string;
@@ -0,0 +1,61 @@
1
+ import { z } from "zod";
2
+ export declare const RpcCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ id: z.ZodOptional<z.ZodString>;
4
+ type: z.ZodLiteral<"prompt">;
5
+ message: z.ZodString;
6
+ }, z.core.$strict>, z.ZodObject<{
7
+ id: z.ZodOptional<z.ZodString>;
8
+ type: z.ZodLiteral<"steer">;
9
+ message: z.ZodString;
10
+ }, z.core.$strict>, z.ZodObject<{
11
+ id: z.ZodOptional<z.ZodString>;
12
+ type: z.ZodLiteral<"follow_up">;
13
+ message: z.ZodString;
14
+ }, z.core.$strict>, z.ZodObject<{
15
+ id: z.ZodOptional<z.ZodString>;
16
+ type: z.ZodLiteral<"abort">;
17
+ }, z.core.$strict>, z.ZodObject<{
18
+ id: z.ZodOptional<z.ZodString>;
19
+ type: z.ZodLiteral<"get_state">;
20
+ }, z.core.$strict>, z.ZodObject<{
21
+ id: z.ZodOptional<z.ZodString>;
22
+ type: z.ZodLiteral<"get_queue">;
23
+ }, z.core.$strict>, z.ZodObject<{
24
+ id: z.ZodOptional<z.ZodString>;
25
+ type: z.ZodLiteral<"clear_queue">;
26
+ }, z.core.$strict>, z.ZodObject<{
27
+ id: z.ZodOptional<z.ZodString>;
28
+ type: z.ZodLiteral<"approval_decision">;
29
+ approvalId: z.ZodString;
30
+ decision: z.ZodEnum<{
31
+ always: "always";
32
+ deny: "deny";
33
+ once: "once";
34
+ }>;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ id: z.ZodOptional<z.ZodString>;
37
+ type: z.ZodLiteral<"write_commit">;
38
+ writeId: z.ZodString;
39
+ }, z.core.$strict>, z.ZodObject<{
40
+ id: z.ZodOptional<z.ZodString>;
41
+ type: z.ZodLiteral<"checkpoint">;
42
+ label: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strict>, z.ZodObject<{
44
+ id: z.ZodOptional<z.ZodString>;
45
+ type: z.ZodLiteral<"get_tree">;
46
+ }, z.core.$strict>, z.ZodObject<{
47
+ id: z.ZodOptional<z.ZodString>;
48
+ type: z.ZodLiteral<"rewind">;
49
+ nodeId: z.ZodString;
50
+ }, z.core.$strict>, z.ZodObject<{
51
+ id: z.ZodOptional<z.ZodString>;
52
+ type: z.ZodLiteral<"unrevert">;
53
+ }, z.core.$strict>, z.ZodObject<{
54
+ id: z.ZodOptional<z.ZodString>;
55
+ type: z.ZodLiteral<"fork">;
56
+ nodeId: z.ZodString;
57
+ }, z.core.$strict>, z.ZodObject<{
58
+ id: z.ZodOptional<z.ZodString>;
59
+ type: z.ZodLiteral<"shutdown">;
60
+ }, z.core.$strict>], "type">;
61
+ export type RpcCommand = z.infer<typeof RpcCommandSchema>;
@@ -0,0 +1,54 @@
1
+ import type { Readable, Writable } from "node:stream";
2
+ import type { AgentQueueSnapshot } from "../agent/message-queue.js";
3
+ import type { SessionOutput } from "../ui/session.js";
4
+ import type { SessionApprovalRequest } from "../ui/session.js";
5
+ import type { ApprovalDecision } from "../tools/runtime.js";
6
+ export interface RpcSessionLike {
7
+ readonly active: boolean;
8
+ start(): Promise<void>;
9
+ submit(prompt: string): Promise<void>;
10
+ steer(prompt: string): void;
11
+ followUp(prompt: string): void;
12
+ interrupt(): "cancelled" | "exit";
13
+ queueSnapshot(): AgentQueueSnapshot;
14
+ clearQueue(): AgentQueueSnapshot;
15
+ whenIdle(): Promise<void>;
16
+ close(): Promise<void>;
17
+ }
18
+ export interface RpcRuntimeLike {
19
+ readonly sessionId: string;
20
+ readonly session: RpcSessionLike;
21
+ readonly services?: {
22
+ checkpoint?(label?: string): Promise<unknown>;
23
+ tree?(): readonly unknown[];
24
+ rewind?(nodeId: string): Promise<void>;
25
+ unrevert?(): Promise<void>;
26
+ fork?(nodeId: string): Promise<void>;
27
+ };
28
+ readonly approvals?: {
29
+ readonly pending: SessionApprovalRequest | undefined;
30
+ resolve(decision: ApprovalDecision): void;
31
+ };
32
+ readonly rpcApprovals?: boolean;
33
+ readonly rpcWrites?: {
34
+ readonly pendingId: string | undefined;
35
+ commit(id: string): void;
36
+ dispose(): void;
37
+ };
38
+ dispose(): Promise<void>;
39
+ }
40
+ export interface FlavorRpcServerOptions {
41
+ input: Readable;
42
+ output: Writable;
43
+ workspace: string;
44
+ createRuntime(options: {
45
+ workspace: string;
46
+ output: (event: SessionOutput) => void;
47
+ }): Promise<RpcRuntimeLike>;
48
+ onRecord?(kind: "command" | "response" | "output", payload: unknown): void | Promise<void>;
49
+ }
50
+ export declare class FlavorRpcServer {
51
+ #private;
52
+ constructor(options: FlavorRpcServerOptions);
53
+ start(): Promise<void>;
54
+ }
@@ -0,0 +1,19 @@
1
+ export { createProductionRuntime } from "../production.js";
2
+ export { createProductionRuntime as createFlavorRuntime } from "../production.js";
3
+ export type { ProductionRuntime, ProductionRuntimeOptions } from "../production.js";
4
+ export { FlavorSession } from "../ui/session.js";
5
+ export type { SessionOutput, SessionServices } from "../ui/session.js";
6
+ export { AgentMessageQueue } from "../agent/message-queue.js";
7
+ export type { AgentQueueSnapshot, AgentQueueKind, AgentQueueMode, AgentMessageQueueOptions, } from "../agent/message-queue.js";
8
+ export { FlavorRpcServer } from "../rpc/server.js";
9
+ export type { FlavorRpcServerOptions, RpcRuntimeLike, RpcSessionLike } from "../rpc/server.js";
10
+ export { TraceRecorder } from "../trace/recorder.js";
11
+ export { replayTrace, replayOutputEvents } from "../trace/replay.js";
12
+ export type { TraceRecord, TraceKind } from "../trace/schema.js";
13
+ export { SessionHistory } from "../session/tree.js";
14
+ export type { SessionTreeNode, SessionHistoryOptions } from "../session/tree.js";
15
+ export { WorkspaceCheckpointStore } from "../session/checkpoint.js";
16
+ export type { WorkspaceCheckpoint, WorkspaceCheckpointStoreOptions, CheckpointFile } from "../session/checkpoint.js";
17
+ export { DockerExecutionEnvironment, buildDockerInvocation } from "../execution/docker.js";
18
+ export type { ExecutionEnvironment, ExecutionRequest, ExecutionResult } from "../execution/types.js";
19
+ export type { AgentEvent } from "../agent/types.js";
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
3
+ import {
4
+ FlavorRpcServer,
5
+ TraceRecordSchema,
6
+ TraceRecorder
7
+ } from "../chunk-M744K7MK.js";
8
+ import {
9
+ AgentMessageQueue,
10
+ DockerExecutionEnvironment,
11
+ FlavorSession,
12
+ SessionHistory,
13
+ WorkspaceCheckpointStore,
14
+ buildDockerInvocation,
15
+ createProductionRuntime
16
+ } from "../chunk-BU64GNXE.js";
17
+ import "../chunk-MVIMQEQT.js";
18
+ import "../chunk-VOCZVFP7.js";
19
+ import "../chunk-JZ322RCJ.js";
20
+
21
+ // src/trace/replay.ts
22
+ import { readFile } from "fs/promises";
23
+ async function replayTrace(path, sessionId) {
24
+ const raw = await readFile(path, "utf8");
25
+ const records = raw.split(/\r?\n/).filter(Boolean).map((line) => TraceRecordSchema.parse(JSON.parse(line)));
26
+ let previous = 0;
27
+ for (const record of records) {
28
+ if (record.sequence <= previous) throw new Error("Trace sequence is not strictly increasing");
29
+ previous = record.sequence;
30
+ }
31
+ return sessionId === void 0 ? records : records.filter((record) => record.sessionId === sessionId);
32
+ }
33
+ async function* replayOutputEvents(path, sessionId) {
34
+ const records = await replayTrace(path, sessionId);
35
+ for (const record of records) {
36
+ if (record.kind === "output") yield record.payload;
37
+ }
38
+ }
39
+ export {
40
+ AgentMessageQueue,
41
+ DockerExecutionEnvironment,
42
+ FlavorRpcServer,
43
+ FlavorSession,
44
+ SessionHistory,
45
+ TraceRecorder,
46
+ WorkspaceCheckpointStore,
47
+ buildDockerInvocation,
48
+ createProductionRuntime as createFlavorRuntime,
49
+ createProductionRuntime,
50
+ replayOutputEvents,
51
+ replayTrace
52
+ };
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/trace/replay.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\n\nimport { TraceRecordSchema, type TraceRecord } from \"./schema.js\";\n\nexport async function replayTrace(path: string, sessionId?: string): Promise<TraceRecord[]> {\n const raw = await readFile(path, \"utf8\");\n const records = raw.split(/\\r?\\n/).filter(Boolean).map((line) => TraceRecordSchema.parse(JSON.parse(line)));\n let previous = 0;\n for (const record of records) {\n if (record.sequence <= previous) throw new Error(\"Trace sequence is not strictly increasing\");\n previous = record.sequence;\n }\n return sessionId === undefined ? records : records.filter((record) => record.sessionId === sessionId);\n}\n\nexport async function* replayOutputEvents(path: string, sessionId?: string): AsyncIterable<unknown> {\n const records = await replayTrace(path, sessionId);\n for (const record of records) {\n if (record.kind === \"output\") yield record.payload;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AAIzB,eAAsB,YAAY,MAAc,WAA4C;AAC1F,QAAM,MAAM,MAAM,SAAS,MAAM,MAAM;AACvC,QAAM,UAAU,IAAI,MAAM,OAAO,EAAE,OAAO,OAAO,EAAE,IAAI,CAAC,SAAS,kBAAkB,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC;AAC1G,MAAI,WAAW;AACf,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,YAAY,SAAU,OAAM,IAAI,MAAM,2CAA2C;AAC5F,eAAW,OAAO;AAAA,EACpB;AACA,SAAO,cAAc,SAAY,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,cAAc,SAAS;AACtG;AAEA,gBAAuB,mBAAmB,MAAc,WAA4C;AAClG,QAAM,UAAU,MAAM,YAAY,MAAM,SAAS;AACjD,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,SAAS,SAAU,OAAM,OAAO;AAAA,EAC7C;AACF;","names":[]}
@@ -0,0 +1,25 @@
1
+ export interface CheckpointFile {
2
+ path: string;
3
+ digest: string;
4
+ size: number;
5
+ mode: number;
6
+ }
7
+ export interface WorkspaceCheckpoint {
8
+ version: 1;
9
+ id: string;
10
+ createdAt: string;
11
+ label?: string;
12
+ files: CheckpointFile[];
13
+ }
14
+ export interface WorkspaceCheckpointStoreOptions {
15
+ workspace: string;
16
+ maxFileBytes?: number;
17
+ maxTotalBytes?: number;
18
+ }
19
+ export declare class WorkspaceCheckpointStore {
20
+ #private;
21
+ constructor(options: WorkspaceCheckpointStoreOptions);
22
+ create(label?: string): Promise<WorkspaceCheckpoint>;
23
+ load(id: string): Promise<WorkspaceCheckpoint>;
24
+ restore(id: string): Promise<WorkspaceCheckpoint>;
25
+ }
@@ -0,0 +1,154 @@
1
+ import { z } from "zod";
2
+ import { type TranscriptState } from "../ui/transcript.js";
3
+ import type { ModelContent } from "../models/types.js";
4
+ export declare const SESSION_VERSION: 3;
5
+ export declare const DEFAULT_MAX_SESSION_BYTES: number;
6
+ export declare const SessionDocumentSchema: z.ZodObject<{
7
+ sessionId: z.ZodString;
8
+ createdAt: z.ZodString;
9
+ updatedAt: z.ZodString;
10
+ workspace: z.ZodObject<{
11
+ path: z.ZodString;
12
+ }, z.core.$strict>;
13
+ tasks: z.ZodObject<{
14
+ plan: z.ZodOptional<z.ZodObject<{
15
+ tasks: z.ZodArray<z.ZodObject<{
16
+ id: z.ZodString;
17
+ subject: z.ZodString;
18
+ activeForm: z.ZodString;
19
+ status: z.ZodEnum<{
20
+ blocked: "blocked";
21
+ cancelled: "cancelled";
22
+ completed: "completed";
23
+ failed: "failed";
24
+ in_progress: "in_progress";
25
+ pending: "pending";
26
+ }>;
27
+ dependencies: z.ZodArray<z.ZodString>;
28
+ result: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strict>>;
30
+ }, z.core.$strict>>;
31
+ graph: z.ZodOptional<z.ZodObject<{
32
+ nodes: z.ZodArray<z.ZodObject<{
33
+ id: z.ZodString;
34
+ description: z.ZodString;
35
+ dependencies: z.ZodArray<z.ZodString>;
36
+ expectedOutputs: z.ZodArray<z.ZodString>;
37
+ verification: z.ZodArray<z.ZodString>;
38
+ }, z.core.$strict>>;
39
+ }, z.core.$strict>>;
40
+ states: z.ZodRecord<z.ZodString, z.ZodEnum<{
41
+ blocked: "blocked";
42
+ cancelled: "cancelled";
43
+ completed: "completed";
44
+ failed: "failed";
45
+ pending: "pending";
46
+ running: "running";
47
+ }>>;
48
+ results: z.ZodRecord<z.ZodString, z.ZodObject<{
49
+ taskId: z.ZodString;
50
+ status: z.ZodEnum<{
51
+ blocked: "blocked";
52
+ completed: "completed";
53
+ failed: "failed";
54
+ }>;
55
+ summary: z.ZodString;
56
+ filesChanged: z.ZodArray<z.ZodString>;
57
+ commandsRun: z.ZodArray<z.ZodObject<{
58
+ command: z.ZodString;
59
+ exitCode: z.ZodNullable<z.ZodNumber>;
60
+ summary: z.ZodString;
61
+ }, z.core.$strict>>;
62
+ verification: z.ZodArray<z.ZodObject<{
63
+ name: z.ZodString;
64
+ passed: z.ZodBoolean;
65
+ details: z.ZodString;
66
+ }, z.core.$strict>>;
67
+ artifacts: z.ZodArray<z.ZodString>;
68
+ risks: z.ZodArray<z.ZodString>;
69
+ suggestedNextSteps: z.ZodArray<z.ZodString>;
70
+ }, z.core.$strict>>;
71
+ }, z.core.$strict>;
72
+ models: z.ZodObject<{
73
+ main: z.ZodString;
74
+ subagent: z.ZodString;
75
+ }, z.core.$strict>;
76
+ permissionMode: z.ZodPreprocess<z.ZodDefault<z.ZodEnum<{
77
+ acceptEdits: "acceptEdits";
78
+ auto: "auto";
79
+ bubble: "bubble";
80
+ bypassPermissions: "bypassPermissions";
81
+ default: "default";
82
+ plan: "plan";
83
+ }>>>;
84
+ memory: z.ZodOptional<z.ZodObject<{
85
+ status: z.ZodEnum<{
86
+ abandoned: "abandoned";
87
+ active: "active";
88
+ completed: "completed";
89
+ }>;
90
+ taskId: z.ZodOptional<z.ZodString>;
91
+ messageStart: z.ZodOptional<z.ZodNumber>;
92
+ finalizedAt: z.ZodOptional<z.ZodString>;
93
+ transcriptHash: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strict>>;
95
+ version: z.ZodLiteral<3>;
96
+ conversation: z.ZodObject<{
97
+ compact: z.ZodOptional<z.ZodObject<{
98
+ summary: z.ZodString;
99
+ compactedAt: z.ZodString;
100
+ }, z.core.$strict>>;
101
+ messages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
102
+ toolCallId: z.ZodOptional<z.ZodString>;
103
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
104
+ id: z.ZodString;
105
+ name: z.ZodString;
106
+ input: z.ZodUnknown;
107
+ }, z.core.$strict>>>;
108
+ role: z.ZodLiteral<"user">;
109
+ content: z.ZodType<ModelContent, unknown, z.core.$ZodTypeInternals<ModelContent, unknown>>;
110
+ }, z.core.$strict>, z.ZodObject<{
111
+ toolCallId: z.ZodOptional<z.ZodString>;
112
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
113
+ id: z.ZodString;
114
+ name: z.ZodString;
115
+ input: z.ZodUnknown;
116
+ }, z.core.$strict>>>;
117
+ role: z.ZodLiteral<"assistant">;
118
+ content: z.ZodString;
119
+ }, z.core.$strict>, z.ZodObject<{
120
+ toolCallId: z.ZodOptional<z.ZodString>;
121
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
122
+ id: z.ZodString;
123
+ name: z.ZodString;
124
+ input: z.ZodUnknown;
125
+ }, z.core.$strict>>>;
126
+ role: z.ZodLiteral<"tool">;
127
+ content: z.ZodString;
128
+ }, z.core.$strict>], "role">>;
129
+ }, z.core.$strict>;
130
+ timeline: z.ZodObject<{
131
+ version: z.ZodLiteral<1>;
132
+ state: z.ZodCustom<TranscriptState, TranscriptState>;
133
+ }, z.core.$strict>;
134
+ }, z.core.$strict>;
135
+ export type SessionDocument = z.infer<typeof SessionDocumentSchema>;
136
+ export interface SessionEntry {
137
+ sessionId: string;
138
+ createdAt: string;
139
+ updatedAt: string;
140
+ mainModel: string;
141
+ }
142
+ export interface SessionStoreOptions {
143
+ workspace: string;
144
+ maxBytes?: number;
145
+ maxSessions?: number;
146
+ }
147
+ export declare class SessionStore {
148
+ #private;
149
+ constructor(options: SessionStoreOptions);
150
+ save(input: SessionDocument): Promise<void>;
151
+ load(sessionId?: string): Promise<SessionDocument>;
152
+ list(): Promise<SessionEntry[]>;
153
+ delete(sessionId: string): Promise<void>;
154
+ }
@@ -0,0 +1,31 @@
1
+ import type { ContextSnapshot } from "../context/manager.js";
2
+ export interface SessionTreeNode {
3
+ id: string;
4
+ parentId: string | null;
5
+ createdAt: string;
6
+ prompt: string;
7
+ checkpointId: string;
8
+ context: ContextSnapshot;
9
+ }
10
+ export interface SessionHistoryOptions {
11
+ workspace: string;
12
+ sessionId: string;
13
+ restoreContext?(snapshot: ContextSnapshot): void | Promise<void>;
14
+ }
15
+ export declare class SessionHistory {
16
+ #private;
17
+ private constructor();
18
+ static open(options: SessionHistoryOptions): Promise<SessionHistory>;
19
+ get leafId(): string | null;
20
+ tree(): readonly SessionTreeNode[];
21
+ append(input: {
22
+ prompt: string;
23
+ context: ContextSnapshot;
24
+ label?: string;
25
+ }): Promise<SessionTreeNode>;
26
+ checkpoint(label: string | undefined, context: ContextSnapshot): Promise<SessionTreeNode>;
27
+ moveTo(nodeId: string): Promise<void>;
28
+ fork(nodeId: string): Promise<ContextSnapshot>;
29
+ rewind(nodeId: string, currentContext: ContextSnapshot): Promise<void>;
30
+ unrevert(): Promise<void>;
31
+ }
@@ -0,0 +1,12 @@
1
+ import type { LoopVerificationEvidence } from "../loop/types.js";
2
+ export declare const BUILTIN_LOOP_SKILL: {
3
+ readonly name: "loop";
4
+ readonly description: "Iteratively work toward a goal using host-owned verification evidence";
5
+ };
6
+ export interface LoopCyclePromptInput {
7
+ goal: string;
8
+ cycle: number;
9
+ memory?: string;
10
+ verification?: LoopVerificationEvidence;
11
+ }
12
+ export declare function buildLoopCyclePrompt(input: LoopCyclePromptInput): string;