@undefineds.co/linx 0.3.4 → 0.3.7

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 (172) hide show
  1. package/README.md +58 -23
  2. package/dist/generated/version.js +1 -1
  3. package/dist/generated/version.js.map +1 -1
  4. package/dist/index.js +334 -162
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/account-session.js +4 -8
  7. package/dist/lib/account-session.js.map +1 -1
  8. package/dist/lib/ai-command.js +228 -178
  9. package/dist/lib/ai-command.js.map +1 -1
  10. package/dist/lib/auto-mode/archive.js +38 -7
  11. package/dist/lib/auto-mode/archive.js.map +1 -1
  12. package/dist/lib/auto-mode/auth.js.map +1 -1
  13. package/dist/lib/auto-mode/display.js +71 -45
  14. package/dist/lib/auto-mode/display.js.map +1 -1
  15. package/dist/lib/auto-mode/format.js +9 -7
  16. package/dist/lib/auto-mode/format.js.map +1 -1
  17. package/dist/lib/auto-mode/hooks/claude.js +12 -2
  18. package/dist/lib/auto-mode/hooks/claude.js.map +1 -1
  19. package/dist/lib/auto-mode/hooks/codex.js +17 -7
  20. package/dist/lib/auto-mode/hooks/codex.js.map +1 -1
  21. package/dist/lib/auto-mode/hooks/index.js +28 -8
  22. package/dist/lib/auto-mode/hooks/index.js.map +1 -1
  23. package/dist/lib/auto-mode/pod-ai.js +20 -37
  24. package/dist/lib/auto-mode/pod-ai.js.map +1 -1
  25. package/dist/lib/auto-mode/pod-approval.js +124 -195
  26. package/dist/lib/auto-mode/pod-approval.js.map +1 -1
  27. package/dist/lib/auto-mode/pod-persistence.js +169 -90
  28. package/dist/lib/auto-mode/pod-persistence.js.map +1 -1
  29. package/dist/lib/auto-mode/runner.js +683 -81
  30. package/dist/lib/auto-mode/runner.js.map +1 -1
  31. package/dist/lib/auto-mode/secretary.js +186 -41
  32. package/dist/lib/auto-mode/secretary.js.map +1 -1
  33. package/dist/lib/auto-mode-command.js +32 -32
  34. package/dist/lib/auto-mode-command.js.map +1 -1
  35. package/dist/lib/chat-api.js +242 -50
  36. package/dist/lib/chat-api.js.map +1 -1
  37. package/dist/lib/codex-plugin/bridge.js +164 -17
  38. package/dist/lib/codex-plugin/bridge.js.map +1 -1
  39. package/dist/lib/codex-plugin/codex-native-proxy.js +370 -34
  40. package/dist/lib/codex-plugin/codex-native-proxy.js.map +1 -1
  41. package/dist/lib/credentials-store.js +33 -42
  42. package/dist/lib/credentials-store.js.map +1 -1
  43. package/dist/lib/linx-cloud-errors.js +61 -0
  44. package/dist/lib/linx-cloud-errors.js.map +1 -0
  45. package/dist/lib/linx-tui-contract.js +8 -5
  46. package/dist/lib/linx-tui-contract.js.map +1 -1
  47. package/dist/lib/login-command.js +9 -2
  48. package/dist/lib/login-command.js.map +1 -1
  49. package/dist/lib/models.js +3 -20
  50. package/dist/lib/models.js.map +1 -1
  51. package/dist/lib/oidc-auth.js +143 -17
  52. package/dist/lib/oidc-auth.js.map +1 -1
  53. package/dist/lib/oidc-session-storage.js +2 -6
  54. package/dist/lib/oidc-session-storage.js.map +1 -1
  55. package/dist/lib/pi-adapter/auto-input-controller.js +988 -0
  56. package/dist/lib/pi-adapter/auto-input-controller.js.map +1 -0
  57. package/dist/lib/pi-adapter/backend-command.js +2 -0
  58. package/dist/lib/pi-adapter/backend-command.js.map +1 -0
  59. package/dist/lib/pi-adapter/backend-credentials.js +80 -0
  60. package/dist/lib/pi-adapter/backend-credentials.js.map +1 -0
  61. package/dist/lib/pi-adapter/branding.js +246 -108
  62. package/dist/lib/pi-adapter/branding.js.map +1 -1
  63. package/dist/lib/pi-adapter/control-state.js +72 -0
  64. package/dist/lib/pi-adapter/control-state.js.map +1 -0
  65. package/dist/lib/pi-adapter/interactive.js +2634 -30
  66. package/dist/lib/pi-adapter/interactive.js.map +1 -1
  67. package/dist/lib/pi-adapter/pod-approval.js +382 -210
  68. package/dist/lib/pi-adapter/pod-approval.js.map +1 -1
  69. package/dist/lib/pi-adapter/pod-mirror-mapping.js +71 -17
  70. package/dist/lib/pi-adapter/pod-mirror-mapping.js.map +1 -1
  71. package/dist/lib/pi-adapter/pod-mirror.js +531 -64
  72. package/dist/lib/pi-adapter/pod-mirror.js.map +1 -1
  73. package/dist/lib/pi-adapter/pod-native.js +81 -85
  74. package/dist/lib/pi-adapter/pod-native.js.map +1 -1
  75. package/dist/lib/pi-adapter/pod-status-output.js +54 -0
  76. package/dist/lib/pi-adapter/pod-status-output.js.map +1 -0
  77. package/dist/lib/pi-adapter/runtime.js +458 -228
  78. package/dist/lib/pi-adapter/runtime.js.map +1 -1
  79. package/dist/lib/pi-adapter/session-control.js +509 -0
  80. package/dist/lib/pi-adapter/session-control.js.map +1 -0
  81. package/dist/lib/pi-adapter/session.js +35 -22
  82. package/dist/lib/pi-adapter/session.js.map +1 -1
  83. package/dist/lib/pi-adapter/stream.js +89 -32
  84. package/dist/lib/pi-adapter/stream.js.map +1 -1
  85. package/dist/lib/pi-adapter/sync-recovery.js +89 -0
  86. package/dist/lib/pi-adapter/sync-recovery.js.map +1 -0
  87. package/dist/lib/pi-adapter/web-fetch.js +13 -14
  88. package/dist/lib/pi-adapter/web-fetch.js.map +1 -1
  89. package/dist/lib/pod-chat-store.js +254 -78
  90. package/dist/lib/pod-chat-store.js.map +1 -1
  91. package/dist/lib/pod-data-session.js +156 -35
  92. package/dist/lib/pod-data-session.js.map +1 -1
  93. package/dist/lib/solid-auth-store.js +27 -0
  94. package/dist/lib/solid-auth-store.js.map +1 -0
  95. package/dist/lib/solid-auth.js +2 -4
  96. package/dist/lib/solid-auth.js.map +1 -1
  97. package/dist/lib/solid-client-credentials-login.js +100 -0
  98. package/dist/lib/solid-client-credentials-login.js.map +1 -0
  99. package/dist/lib/solid-local-store.js +31 -0
  100. package/dist/lib/solid-local-store.js.map +1 -0
  101. package/dist/lib/symphony/archive.js +328 -18
  102. package/dist/lib/symphony/archive.js.map +1 -1
  103. package/dist/lib/symphony/pod-projection.js +2222 -0
  104. package/dist/lib/symphony/pod-projection.js.map +1 -0
  105. package/dist/lib/symphony-command.js +602 -178
  106. package/dist/lib/symphony-command.js.map +1 -1
  107. package/dist/lib/sync-checkpoint-store.js +74 -0
  108. package/dist/lib/sync-checkpoint-store.js.map +1 -0
  109. package/dist/skills/symphony/SKILL.md +665 -0
  110. package/package.json +15 -9
  111. package/vendor/agent-runtime/dist/agent-runtime.d.ts +137 -0
  112. package/vendor/agent-runtime/dist/agent-runtime.js +211 -0
  113. package/vendor/agent-runtime/dist/auto-mode.d.ts +78 -13
  114. package/vendor/agent-runtime/dist/auto-mode.js +288 -31
  115. package/vendor/agent-runtime/dist/control-plane.d.ts +28 -0
  116. package/vendor/agent-runtime/dist/control-plane.js +79 -0
  117. package/vendor/agent-runtime/dist/file-sync.d.ts +157 -0
  118. package/vendor/agent-runtime/dist/file-sync.js +314 -0
  119. package/vendor/agent-runtime/dist/index.d.ts +7 -0
  120. package/vendor/agent-runtime/dist/index.js +7 -0
  121. package/vendor/agent-runtime/dist/reconciler.d.ts +117 -0
  122. package/vendor/agent-runtime/dist/reconciler.js +361 -0
  123. package/vendor/agent-runtime/dist/symphony.d.ts +128 -8
  124. package/vendor/agent-runtime/dist/symphony.js +362 -57
  125. package/vendor/agent-runtime/dist/sync.d.ts +271 -0
  126. package/vendor/agent-runtime/dist/sync.js +550 -0
  127. package/vendor/agent-runtime/dist/thread-reconciler-controller.d.ts +58 -0
  128. package/vendor/agent-runtime/dist/thread-reconciler-controller.js +137 -0
  129. package/vendor/agent-runtime/dist/turn-controller.js +2 -2
  130. package/vendor/agent-runtime/dist/wake-scheduler.d.ts +67 -0
  131. package/vendor/agent-runtime/dist/wake-scheduler.js +194 -0
  132. package/vendor/agent-runtime/package.json +8 -1
  133. package/vendor/pi-web-access/CHANGELOG.md +387 -0
  134. package/vendor/pi-web-access/LICENSE +21 -0
  135. package/vendor/pi-web-access/README.md +352 -0
  136. package/vendor/pi-web-access/activity.ts +101 -0
  137. package/vendor/pi-web-access/banner.png +0 -0
  138. package/vendor/pi-web-access/chrome-cookies.ts +322 -0
  139. package/vendor/pi-web-access/code-search.ts +107 -0
  140. package/vendor/pi-web-access/curator-page.ts +3359 -0
  141. package/vendor/pi-web-access/curator-server.ts +605 -0
  142. package/vendor/pi-web-access/exa.ts +520 -0
  143. package/vendor/pi-web-access/extract.ts +641 -0
  144. package/vendor/pi-web-access/gemini-api.ts +112 -0
  145. package/vendor/pi-web-access/gemini-search.ts +361 -0
  146. package/vendor/pi-web-access/gemini-url-context.ts +126 -0
  147. package/vendor/pi-web-access/gemini-web-config.ts +52 -0
  148. package/vendor/pi-web-access/gemini-web.ts +396 -0
  149. package/vendor/pi-web-access/github-api.ts +196 -0
  150. package/vendor/pi-web-access/github-extract.ts +634 -0
  151. package/vendor/pi-web-access/index.ts +2346 -0
  152. package/vendor/pi-web-access/package.json +45 -0
  153. package/vendor/pi-web-access/pdf-extract.ts +192 -0
  154. package/vendor/pi-web-access/perplexity.ts +195 -0
  155. package/vendor/pi-web-access/pi-web-fetch-demo.mp4 +0 -0
  156. package/vendor/pi-web-access/rsc-extract.ts +338 -0
  157. package/vendor/pi-web-access/skills/librarian/SKILL.md +195 -0
  158. package/vendor/pi-web-access/storage.ts +72 -0
  159. package/vendor/pi-web-access/summary-review.ts +276 -0
  160. package/vendor/pi-web-access/test/gemini-web-cookie-opt-in.test.mjs +41 -0
  161. package/vendor/pi-web-access/test/pdf-extract.test.mjs +95 -0
  162. package/vendor/pi-web-access/utils.ts +44 -0
  163. package/vendor/pi-web-access/video-extract.ts +378 -0
  164. package/vendor/pi-web-access/youtube-extract.ts +310 -0
  165. package/dist/lib/pi-adapter/auth.js +0 -68
  166. package/dist/lib/pi-adapter/auth.js.map +0 -1
  167. package/dist/lib/pi-adapter/pod-tools.js +0 -140
  168. package/dist/lib/pi-adapter/pod-tools.js.map +0 -1
  169. package/dist/skills/drizzle-solid/SKILL.md +0 -340
  170. package/dist/skills/pod-storage/SKILL.md +0 -100
  171. package/dist/skills/solid-modeling/SKILL.md +0 -274
  172. package/dist/skills/xpod-componentsjs/SKILL.md +0 -284
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@undefineds.co/linx",
3
- "version": "0.3.4",
3
+ "version": "0.3.7",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,17 +12,23 @@
12
12
  "test": "yarn build && node --test --test-concurrency=1 test/**/*.test.mjs"
13
13
  },
14
14
  "dependencies": {
15
- "@inrupt/solid-client-authn-node": "^4.0.0",
16
- "@mariozechner/pi-coding-agent": "^0.73.1",
17
- "@sinclair/typebox": "^0.34.49",
18
- "@undefineds.co/models": "0.2.37",
15
+ "@inrupt/solid-client-authn-node": "^3.1.1",
16
+ "@earendil-works/pi-agent-core": "0.78.0",
17
+ "@earendil-works/pi-ai": "0.78.0",
18
+ "@earendil-works/pi-coding-agent": "0.78.0",
19
+ "@earendil-works/pi-tui": "0.78.0",
20
+ "@undefineds.co/drizzle-solid": "^0.3.14",
21
+ "@undefineds.co/models": "0.2.39",
19
22
  "@zed-industries/codex-acp": "0.14.0",
20
- "n3": "^2.0.3",
21
- "yargs": "^18.0.0"
23
+ "n3": "^1.26.0",
24
+ "pi-web-access": "^0.10.7",
25
+ "ws": "^8.20.0",
26
+ "typebox": "^1.1.38",
27
+ "yargs": "^17.7.2"
22
28
  },
23
29
  "devDependencies": {
24
- "@types/node": "^25.9.1",
25
- "typescript": "^6.0.3"
30
+ "@types/node": "^24.10.1",
31
+ "typescript": "^5.6.2"
26
32
  },
27
33
  "files": [
28
34
  "dist",
@@ -0,0 +1,137 @@
1
+ import type { AgentParticipantRole, AgentTurnTrigger } from './turn-controller.js';
2
+ type MaybePromise<T> = T | Promise<T>;
3
+ export type AgentRuntimeTurnStatus = 'running' | 'completed' | 'failed' | 'cancelled';
4
+ export type AgentRuntimeMessageRole = 'system' | 'user' | 'assistant' | 'tool';
5
+ export type AgentRuntimeMessageSource = 'user' | 'primary-agent' | 'secretary' | 'tool' | 'system';
6
+ export interface AgentRuntimeMessage {
7
+ role: AgentRuntimeMessageRole;
8
+ content: string;
9
+ source?: AgentRuntimeMessageSource;
10
+ createdAt?: string;
11
+ metadata?: Record<string, unknown>;
12
+ }
13
+ export interface AgentRuntimeBackendConfig {
14
+ backend?: string;
15
+ model?: string;
16
+ credentialSource?: string;
17
+ runtime?: string;
18
+ transport?: string;
19
+ endpoint?: string;
20
+ metadata?: Record<string, unknown>;
21
+ }
22
+ export interface AgentRuntimeSkillSnapshot {
23
+ id: string;
24
+ name?: string;
25
+ version?: string;
26
+ source?: string;
27
+ checksum?: string;
28
+ loadPolicy?: string;
29
+ enabled?: boolean;
30
+ }
31
+ export interface AgentRuntimeConfig {
32
+ agent: string;
33
+ role: AgentParticipantRole;
34
+ model: string;
35
+ label?: string;
36
+ runtime?: AgentRuntimeBackendConfig;
37
+ skills?: AgentRuntimeSkillSnapshot[];
38
+ authorityPolicy?: Record<string, unknown>;
39
+ toolPolicy?: Record<string, unknown>;
40
+ systemPrompt?: string;
41
+ metadata?: Record<string, unknown>;
42
+ }
43
+ export interface AgentRuntimeConfigOverrides {
44
+ model?: string;
45
+ runtime?: Partial<AgentRuntimeBackendConfig>;
46
+ skills?: AgentRuntimeSkillSnapshot[];
47
+ authorityPolicy?: Record<string, unknown>;
48
+ toolPolicy?: Record<string, unknown>;
49
+ metadata?: Record<string, unknown>;
50
+ }
51
+ export interface AgentRuntimeConfigSnapshot {
52
+ agent: string;
53
+ role: AgentParticipantRole;
54
+ model: string;
55
+ label?: string;
56
+ runtime?: AgentRuntimeBackendConfig;
57
+ credentialSource?: string;
58
+ skills?: AgentRuntimeSkillSnapshot[];
59
+ authorityPolicy?: Record<string, unknown>;
60
+ toolPolicy?: Record<string, unknown>;
61
+ metadata?: Record<string, unknown>;
62
+ source?: string;
63
+ createdAt: string;
64
+ }
65
+ export interface AgentRuntimeCompletionRequest {
66
+ agent: AgentRuntimeConfig;
67
+ model: string;
68
+ messages: AgentRuntimeMessage[];
69
+ signal?: AbortSignal;
70
+ metadata?: Record<string, unknown>;
71
+ }
72
+ export interface AgentRuntimeCompletionResult {
73
+ content: string;
74
+ reasoningContent?: string;
75
+ finishReason?: string | null;
76
+ usage?: Record<string, unknown>;
77
+ raw?: unknown;
78
+ }
79
+ export type AgentRuntimeComplete = (request: AgentRuntimeCompletionRequest) => MaybePromise<AgentRuntimeCompletionResult>;
80
+ export interface AgentRuntimeRunRecord {
81
+ id: string;
82
+ agent: string;
83
+ role: AgentParticipantRole;
84
+ model: string;
85
+ runtime?: AgentRuntimeBackendConfig;
86
+ trigger?: AgentTurnTrigger | string;
87
+ input?: string;
88
+ status: AgentRuntimeTurnStatus;
89
+ output?: string;
90
+ error?: string;
91
+ startedAt: string;
92
+ completedAt?: string;
93
+ metadata?: Record<string, unknown>;
94
+ }
95
+ export interface AgentRuntimeRunStepRecord {
96
+ id: string;
97
+ run: string;
98
+ stepType: string;
99
+ message?: string;
100
+ data?: Record<string, unknown>;
101
+ createdAt: string;
102
+ }
103
+ export interface AgentRuntimeTurnInput {
104
+ trigger?: AgentTurnTrigger | string;
105
+ input?: string;
106
+ messages: AgentRuntimeMessage[];
107
+ signal?: AbortSignal;
108
+ metadata?: Record<string, unknown>;
109
+ now?: () => Date;
110
+ randomId?: string;
111
+ }
112
+ export interface AgentRuntimeTurnResult {
113
+ run: AgentRuntimeRunRecord;
114
+ steps: AgentRuntimeRunStepRecord[];
115
+ content: string;
116
+ reasoningContent?: string;
117
+ finishReason?: string | null;
118
+ usage?: Record<string, unknown>;
119
+ raw?: unknown;
120
+ }
121
+ export interface AgentRuntime {
122
+ readonly config: AgentRuntimeConfig;
123
+ runTurn(input: AgentRuntimeTurnInput): Promise<AgentRuntimeTurnResult>;
124
+ }
125
+ export declare class AgentRuntimeTurnError extends Error {
126
+ readonly run: AgentRuntimeRunRecord;
127
+ readonly steps: AgentRuntimeRunStepRecord[];
128
+ readonly cause?: unknown | undefined;
129
+ constructor(message: string, run: AgentRuntimeRunRecord, steps: AgentRuntimeRunStepRecord[], cause?: unknown | undefined);
130
+ }
131
+ export declare function createAgentRuntime(config: AgentRuntimeConfig, complete: AgentRuntimeComplete): AgentRuntime;
132
+ export declare function resolveAgentRuntimeConfig(defaults: AgentRuntimeConfig, overrides?: AgentRuntimeConfigOverrides): AgentRuntimeConfig;
133
+ export declare function createAgentRuntimeConfigSnapshot(config: AgentRuntimeConfig, input?: {
134
+ createdAt?: string | Date;
135
+ source?: string;
136
+ }): AgentRuntimeConfigSnapshot;
137
+ export {};
@@ -0,0 +1,211 @@
1
+ export class AgentRuntimeTurnError extends Error {
2
+ run;
3
+ steps;
4
+ cause;
5
+ constructor(message, run, steps, cause) {
6
+ super(message);
7
+ this.run = run;
8
+ this.steps = steps;
9
+ this.cause = cause;
10
+ this.name = 'AgentRuntimeTurnError';
11
+ }
12
+ }
13
+ export function createAgentRuntime(config, complete) {
14
+ return new ConfiguredAgentRuntime(config, complete);
15
+ }
16
+ export function resolveAgentRuntimeConfig(defaults, overrides = {}) {
17
+ const runtime = resolveAgentRuntimeBackendConfig(defaults.runtime, overrides.runtime, overrides.model);
18
+ const model = normalizeRuntimeConfigString(overrides.model)
19
+ ?? normalizeRuntimeConfigString(overrides.runtime?.model)
20
+ ?? normalizeRuntimeConfigString(runtime?.model)
21
+ ?? defaults.model;
22
+ return {
23
+ ...defaults,
24
+ model,
25
+ ...(runtime ? { runtime: { ...runtime, model } } : {}),
26
+ ...(overrides.skills ? { skills: cloneSkillSnapshots(overrides.skills) } : {}),
27
+ ...(overrides.authorityPolicy ? { authorityPolicy: { ...overrides.authorityPolicy } } : {}),
28
+ ...(overrides.toolPolicy ? { toolPolicy: { ...overrides.toolPolicy } } : {}),
29
+ metadata: mergeRuntimeMetadata(defaults.metadata, overrides.metadata),
30
+ };
31
+ }
32
+ export function createAgentRuntimeConfigSnapshot(config, input = {}) {
33
+ const createdAt = input.createdAt instanceof Date
34
+ ? input.createdAt.toISOString()
35
+ : typeof input.createdAt === 'string' && input.createdAt.trim().length > 0
36
+ ? input.createdAt
37
+ : new Date().toISOString();
38
+ return omitUndefined({
39
+ agent: config.agent,
40
+ role: config.role,
41
+ model: config.model,
42
+ label: config.label,
43
+ runtime: config.runtime ? { ...config.runtime } : undefined,
44
+ credentialSource: config.runtime?.credentialSource,
45
+ skills: config.skills ? cloneSkillSnapshots(config.skills) : undefined,
46
+ authorityPolicy: config.authorityPolicy ? { ...config.authorityPolicy } : undefined,
47
+ toolPolicy: config.toolPolicy ? { ...config.toolPolicy } : undefined,
48
+ metadata: config.metadata ? { ...config.metadata } : undefined,
49
+ source: input.source,
50
+ createdAt,
51
+ });
52
+ }
53
+ class ConfiguredAgentRuntime {
54
+ config;
55
+ complete;
56
+ constructor(config, complete) {
57
+ this.config = config;
58
+ this.complete = complete;
59
+ }
60
+ async runTurn(input) {
61
+ const now = input.now ?? (() => new Date());
62
+ const run = createRunRecord(this.config, input, now);
63
+ const steps = [];
64
+ const nextStep = createStepFactory(run.id, now);
65
+ steps.push(nextStep('run.created', 'Runtime turn created', {
66
+ agent: this.config.agent,
67
+ role: this.config.role,
68
+ model: this.config.model,
69
+ runtime: this.config.runtime,
70
+ runtimeSnapshot: run.metadata?.runtimeSnapshot,
71
+ trigger: input.trigger,
72
+ }));
73
+ const messages = buildRuntimeMessages(this.config, input.messages);
74
+ steps.push(nextStep('runtime.input.prepared', 'Runtime input prepared', {
75
+ messageCount: messages.length,
76
+ input: input.input,
77
+ }));
78
+ try {
79
+ const result = await this.complete({
80
+ agent: this.config,
81
+ model: this.config.model,
82
+ messages,
83
+ signal: input.signal,
84
+ metadata: {
85
+ ...(this.config.runtime ? { runtime: this.config.runtime } : {}),
86
+ ...this.config.metadata,
87
+ ...input.metadata,
88
+ },
89
+ });
90
+ const completedAt = now().toISOString();
91
+ const content = result.content ?? '';
92
+ run.status = 'completed';
93
+ run.output = content;
94
+ run.completedAt = completedAt;
95
+ steps.push(nextStep('runtime.output.completed', 'Runtime output completed', {
96
+ finishReason: result.finishReason,
97
+ outputLength: content.length,
98
+ usage: result.usage,
99
+ }));
100
+ return {
101
+ run,
102
+ steps,
103
+ content,
104
+ reasoningContent: result.reasoningContent,
105
+ finishReason: result.finishReason,
106
+ usage: result.usage,
107
+ raw: result.raw,
108
+ };
109
+ }
110
+ catch (cause) {
111
+ const message = cause instanceof Error ? cause.message : String(cause);
112
+ const completedAt = now().toISOString();
113
+ run.status = 'failed';
114
+ run.error = message;
115
+ run.completedAt = completedAt;
116
+ steps.push(nextStep('runtime.error', message, {
117
+ error: message,
118
+ }));
119
+ throw new AgentRuntimeTurnError(message, run, steps, cause);
120
+ }
121
+ }
122
+ }
123
+ function buildRuntimeMessages(config, messages) {
124
+ const systemPrompt = config.systemPrompt?.trim();
125
+ if (!systemPrompt) {
126
+ return messages;
127
+ }
128
+ return [
129
+ {
130
+ role: 'system',
131
+ source: 'system',
132
+ content: systemPrompt,
133
+ },
134
+ ...messages,
135
+ ];
136
+ }
137
+ function createRunRecord(config, input, now) {
138
+ const startedAt = now().toISOString();
139
+ const runtimeSnapshot = createAgentRuntimeConfigSnapshot(config, {
140
+ createdAt: startedAt,
141
+ source: 'agent-runtime.run',
142
+ });
143
+ return {
144
+ id: createRuntimeRecordId('run', input.randomId),
145
+ agent: config.agent,
146
+ role: config.role,
147
+ model: config.model,
148
+ ...(config.runtime ? { runtime: config.runtime } : {}),
149
+ trigger: input.trigger,
150
+ input: input.input,
151
+ status: 'running',
152
+ startedAt,
153
+ metadata: {
154
+ ...(config.runtime ? { runtime: config.runtime } : {}),
155
+ ...config.metadata,
156
+ ...input.metadata,
157
+ ...(config.label ? { label: config.label } : {}),
158
+ runtimeSnapshot,
159
+ },
160
+ };
161
+ }
162
+ function resolveAgentRuntimeBackendConfig(defaults, overrides, modelOverride) {
163
+ if (!defaults && !overrides && !modelOverride) {
164
+ return undefined;
165
+ }
166
+ const metadata = mergeRuntimeMetadata(defaults?.metadata, overrides?.metadata);
167
+ return {
168
+ ...defaults,
169
+ ...overrides,
170
+ ...(normalizeRuntimeConfigString(modelOverride) ? { model: normalizeRuntimeConfigString(modelOverride) } : {}),
171
+ ...(metadata ? { metadata } : {}),
172
+ };
173
+ }
174
+ function mergeRuntimeMetadata(defaults, overrides) {
175
+ if (!defaults && !overrides) {
176
+ return undefined;
177
+ }
178
+ return {
179
+ ...defaults,
180
+ ...overrides,
181
+ };
182
+ }
183
+ function cloneSkillSnapshots(skills) {
184
+ return skills.map((skill) => ({ ...skill }));
185
+ }
186
+ function omitUndefined(record) {
187
+ return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
188
+ }
189
+ function normalizeRuntimeConfigString(value) {
190
+ return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
191
+ }
192
+ function createStepFactory(run, now) {
193
+ let sequence = 0;
194
+ return (stepType, message, data) => {
195
+ sequence += 1;
196
+ return {
197
+ id: `${run}-step-${String(sequence).padStart(4, '0')}`,
198
+ run,
199
+ stepType,
200
+ ...(message ? { message } : {}),
201
+ ...(data ? { data } : {}),
202
+ createdAt: now().toISOString(),
203
+ };
204
+ };
205
+ }
206
+ function createRuntimeRecordId(prefix, randomId) {
207
+ const suffix = randomId?.trim()
208
+ || globalThis.crypto?.randomUUID?.()
209
+ || Math.random().toString(36).slice(2, 10).padEnd(8, '0');
210
+ return `${prefix}_${suffix}`;
211
+ }
@@ -1,9 +1,11 @@
1
- export type AutoModeBackend = 'codex' | 'claude' | 'codebuddy';
2
- export type AutoModeMode = 'manual' | 'smart' | 'auto';
1
+ export type AutoModeBackend = 'linx' | 'codex' | 'claude' | 'codebuddy';
2
+ export type AutoModeWorkerBackend = AutoModeBackend;
3
+ export type AutoModeMode = 'off' | 'auto';
4
+ export type LegacyAutoModeMode = AutoModeMode | 'manual' | 'smart';
3
5
  export type AutoModeSessionStatus = 'running' | 'completed' | 'failed';
4
6
  export type AutoModeOutputStream = 'stdout' | 'stderr' | 'system';
5
- export type AutoModeCredentialSource = 'cloud';
6
- export type AutoModeResolvedCredentialSource = 'cloud';
7
+ export type AutoModeCredentialSource = 'cloud' | 'local';
8
+ export type AutoModeResolvedCredentialSource = 'cloud' | 'local';
7
9
  type LegacyAutoModeCredentialSource = AutoModeCredentialSource | 'auto' | 'local';
8
10
  export type AutoModeApprovalSource = 'local' | 'remote' | 'hybrid';
9
11
  export type AutoModeRuntime = 'local';
@@ -32,7 +34,8 @@ export interface AutoModeSessionRecord {
32
34
  backend: AutoModeBackend;
33
35
  runtime: AutoModeRuntime;
34
36
  transport?: AutoModeTransport;
35
- mode: AutoModeMode;
37
+ mode: LegacyAutoModeMode;
38
+ autoEnabled?: boolean;
36
39
  goalMode?: boolean;
37
40
  cwd: string;
38
41
  model?: string;
@@ -50,21 +53,39 @@ export interface AutoModeSessionRecord {
50
53
  signal?: string | null;
51
54
  error?: string;
52
55
  backendSessionId?: string;
56
+ metadata?: Record<string, unknown>;
53
57
  archiveDir: string;
54
58
  eventsFile: string;
55
59
  }
56
60
  export type AutoModeApprovalRequestKind = 'command-approval' | 'file-change-approval' | 'permissions-approval' | 'codex-approval';
57
61
  export type AutoModeInteractionRequestKind = AutoModeApprovalRequestKind | 'user-input';
58
- export type AutoModeApprovalDecision = 'accept' | 'accept_for_session' | 'decline' | 'cancel';
62
+ export type AutoModeApprovalDecision = 'accept' | 'accept_for_session' | 'accept_always' | 'decline' | 'cancel';
59
63
  export type AutoModeSecretaryApprovalDecision = 'accept' | 'decline' | 'cancel';
60
- export type AutoModeApprovalOptionKind = 'allow_once' | 'allow_always' | 'reject_once' | 'reject_always' | (string & {});
64
+ export type AutoModeApprovalOptionKind = 'allow_once' | 'allow_for_session' | 'allow_always' | 'reject_once' | 'reject_always' | (string & {});
61
65
  export type AutoModeApprovalRisk = 'low' | 'medium' | 'high';
66
+ export type AutoModeGrantScope = 'session' | 'durable';
62
67
  export interface AutoModeApprovalOption {
63
68
  optionId: string;
64
69
  label: string;
65
70
  kind?: AutoModeApprovalOptionKind;
66
71
  description?: string;
67
72
  }
73
+ export type AutoModeStoredApprovalStatus = 'pending' | 'approved' | 'rejected' | (string & {});
74
+ export interface AutoModeApprovalDecisionReason {
75
+ source?: string;
76
+ decision?: AutoModeApprovalDecision;
77
+ note?: string;
78
+ selectedOptionId?: string;
79
+ selectedLabel?: string;
80
+ }
81
+ export interface BuildAutoModeApprovalDecisionReasonOptions {
82
+ source?: string;
83
+ decision?: AutoModeApprovalDecision;
84
+ note?: string;
85
+ selectedOption?: AutoModeApprovalOption;
86
+ selectedOptionId?: string;
87
+ selectedLabel?: string;
88
+ }
68
89
  interface AutoModeInteractionRequestBase {
69
90
  kind: AutoModeInteractionRequestKind;
70
91
  message: string;
@@ -138,7 +159,8 @@ export declare function autoModeApprovalToolName(request: AutoModeApprovalReques
138
159
  export declare function autoModeApprovalRisk(request: AutoModeApprovalRequest): AutoModeApprovalRisk;
139
160
  export declare function autoModeApprovalRequestMessage(request: AutoModeApprovalRequest): string;
140
161
  export interface ParseAutoModeSecretaryRecommendationOptions {
141
- mode: AutoModeMode;
162
+ mode: LegacyAutoModeMode;
163
+ autoEnabled?: boolean;
142
164
  request: AutoModeInteractionRequest;
143
165
  defaultReactionWindowMs?: number;
144
166
  }
@@ -192,7 +214,8 @@ export interface AutoModeThreadMetadata extends Record<string, unknown> {
192
214
  backend: AutoModeBackend;
193
215
  runtime: AutoModeRuntime;
194
216
  transport?: AutoModeTransport;
195
- mode: AutoModeMode;
217
+ mode: LegacyAutoModeMode;
218
+ autoEnabled?: boolean;
196
219
  goalMode?: boolean;
197
220
  cwd: string;
198
221
  model?: string;
@@ -202,6 +225,31 @@ export interface AutoModeThreadMetadata extends Record<string, unknown> {
202
225
  status: AutoModeSessionStatus;
203
226
  backendSessionId?: string;
204
227
  }
228
+ export type AutoModeCommandTargetRole = 'control-command' | 'peer-command';
229
+ export type AutoModeAutoControl = {
230
+ action: 'status';
231
+ } | {
232
+ action: 'set';
233
+ enabled: boolean;
234
+ initialInput?: string;
235
+ };
236
+ export interface AutoModeControlCommandRoute {
237
+ kind: 'control-command';
238
+ targetRole: 'control-command';
239
+ command: 'auto' | (string & {});
240
+ text: string;
241
+ auto?: AutoModeAutoControl;
242
+ }
243
+ export interface AutoModePeerCommandRoute {
244
+ kind: 'peer-command';
245
+ targetRole: 'peer-command';
246
+ command: 'goal' | (string & {});
247
+ text: string;
248
+ secretaryBehavior?: {
249
+ goalMode?: boolean;
250
+ };
251
+ }
252
+ export type AutoModeCommandRoute = AutoModeControlCommandRoute | AutoModePeerCommandRoute;
205
253
  export type AutoModeTranscriptMessageRole = 'user' | 'assistant' | 'system';
206
254
  export type AutoModeTranscriptMessageSource = 'user' | 'primary-agent' | 'secretary' | 'tool' | 'system';
207
255
  export interface AutoModeTranscriptMessage {
@@ -219,6 +267,8 @@ export interface AutoModeArchiveRelativePaths {
219
267
  sessionFile: string;
220
268
  eventsFile: string;
221
269
  }
270
+ export declare function resolveAutoModeCommandRoute(input: string | null | undefined): AutoModeCommandRoute | null;
271
+ export declare function resolveAutoModePeerCommand(input: string | null | undefined): AutoModePeerCommandRoute | null;
222
272
  export declare const AUTO_MODE_HOME_DIRNAME = "auto-mode";
223
273
  export declare const AUTO_MODE_SESSIONS_DIRNAME = "sessions";
224
274
  export declare const AUTO_MODE_SESSION_FILE_NAME = "session.json";
@@ -226,9 +276,21 @@ export declare const AUTO_MODE_EVENTS_FILE_NAME = "events.jsonl";
226
276
  export declare function normalizeAutoModeUserInputQuestion(value: unknown, fallbackId?: string): AutoModeUserInputQuestion | null;
227
277
  export declare function resolveAutoModeQuestionAnswer(question: AutoModeUserInputQuestion, answer: string): string[];
228
278
  export declare function normalizeAutoModeApprovalOptions(value: unknown): AutoModeApprovalOption[];
279
+ export declare function parseAutoModeApprovalOptions(value: unknown): AutoModeApprovalOption[];
280
+ export declare function encodeAutoModeApprovalOptions(options: AutoModeApprovalOption[] | undefined): string | undefined;
281
+ export declare function buildAutoModeApprovalDecisionReason(options: AutoModeApprovalDecision | BuildAutoModeApprovalDecisionReasonOptions, note?: string): string;
282
+ export declare function parseAutoModeApprovalDecisionReason(value: unknown): AutoModeApprovalDecisionReason | null;
283
+ export declare function autoModeApprovalDecisionForOption(option: AutoModeApprovalOption): AutoModeApprovalDecision;
284
+ export declare function autoModeApprovalDecisionForStoredApproval(input: {
285
+ status: AutoModeStoredApprovalStatus | undefined;
286
+ reason?: unknown;
287
+ approvalOptions?: unknown;
288
+ }): AutoModeApprovalDecision | null;
289
+ export declare function shouldMaterializeAutoModeGrant(decision: AutoModeApprovalDecision | null | undefined): boolean;
290
+ export declare function autoModeGrantScopeForDecision(decision: AutoModeApprovalDecision | null | undefined): AutoModeGrantScope | null;
229
291
  export declare function createAutoModeSessionId(options?: CreateAutoModeSessionIdOptions): string;
230
- export declare function normalizeAutoModeCredentialSource(_source?: LegacyAutoModeCredentialSource | null): AutoModeCredentialSource;
231
- export declare function shouldAttemptCloudCredentialProbe(_requestedSource: LegacyAutoModeCredentialSource, _localAuthStatus: AutoModeAuthStatus): boolean;
292
+ export declare function normalizeAutoModeCredentialSource(source?: LegacyAutoModeCredentialSource | null): AutoModeCredentialSource;
293
+ export declare function shouldAttemptCloudCredentialProbe(requestedSource: LegacyAutoModeCredentialSource, _localAuthStatus: AutoModeAuthStatus): boolean;
232
294
  export declare function formatAutoModeAutoFallbackMessage(localMessage: string, detail: string): string;
233
295
  export declare function resolveAutoModeCredentialSourceResolution(input: {
234
296
  requestedSource?: LegacyAutoModeCredentialSource | null;
@@ -237,11 +299,13 @@ export declare function resolveAutoModeCredentialSourceResolution(input: {
237
299
  defaultLocalMessage?: string;
238
300
  }): AutoModeCredentialSourceResolution;
239
301
  export declare function resolveAutoModeAutoApprovalDecision(input: {
240
- mode: AutoModeMode;
302
+ mode: LegacyAutoModeMode;
303
+ autoEnabled?: boolean;
241
304
  request: AutoModeApprovalRequest;
242
305
  }): AutoModeApprovalDecision | null;
243
306
  export declare function createFallbackAutoModeSecretaryRecommendation(input: {
244
- mode: AutoModeMode;
307
+ mode: LegacyAutoModeMode;
308
+ autoEnabled?: boolean;
245
309
  request: AutoModeInteractionRequest;
246
310
  }): AutoModeSecretaryRecommendation | null;
247
311
  export declare function parseAutoModeSecretaryRecommendation(text: string, options: ParseAutoModeSecretaryRecommendationOptions): AutoModeSecretaryRecommendation | null;
@@ -260,6 +324,7 @@ export declare function isTrustedAutoModeCommand(command: string | null | undefi
260
324
  export declare function normalizeCodexAppServerInteractionRequest(message: Record<string, unknown>): AutoModeInteractionRequest | null;
261
325
  export declare function resolveAutoModeInteractionAutoResponse(input: {
262
326
  mode: AutoModeMode;
327
+ autoEnabled?: boolean;
263
328
  request: AutoModeInteractionRequest;
264
329
  }): unknown | null;
265
330
  export declare function buildCodexApprovalResponse(request: AutoModeApprovalRequest, decision: AutoModeApprovalDecision): unknown;