@undefineds.co/linx 0.2.16 → 0.2.17

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 (119) hide show
  1. package/README.md +6 -3
  2. package/dist/generated/version.js +3 -0
  3. package/dist/generated/version.js.map +1 -0
  4. package/dist/index.js +139 -259
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/account-api.js +1 -1
  7. package/dist/lib/account-api.js.map +1 -1
  8. package/dist/lib/account-session.js +1 -1
  9. package/dist/lib/account-session.js.map +1 -1
  10. package/dist/lib/ai-command.js +105 -56
  11. package/dist/lib/ai-command.js.map +1 -1
  12. package/dist/lib/chat-api.js +19 -177
  13. package/dist/lib/chat-api.js.map +1 -1
  14. package/dist/lib/codex-plugin/bridge.js.map +1 -1
  15. package/dist/lib/codex-plugin/codex-native-proxy.js.map +1 -1
  16. package/dist/lib/codex-plugin/index.js.map +1 -1
  17. package/dist/lib/codex-plugin/runner.js.map +1 -1
  18. package/dist/lib/credentials-store.js +1 -7
  19. package/dist/lib/credentials-store.js.map +1 -1
  20. package/dist/lib/default-model.js +0 -1
  21. package/dist/lib/default-model.js.map +1 -1
  22. package/dist/lib/login-command.js +2 -17
  23. package/dist/lib/login-command.js.map +1 -1
  24. package/dist/lib/models.js +27 -2
  25. package/dist/lib/models.js.map +1 -1
  26. package/dist/lib/oidc-auth.js +13 -78
  27. package/dist/lib/oidc-auth.js.map +1 -1
  28. package/dist/lib/oidc-session-storage.js.map +1 -1
  29. package/dist/lib/pi-adapter/auth.js +5 -12
  30. package/dist/lib/pi-adapter/auth.js.map +1 -1
  31. package/dist/lib/pi-adapter/branding.js +76 -554
  32. package/dist/lib/pi-adapter/branding.js.map +1 -1
  33. package/dist/lib/pi-adapter/index.js.map +1 -1
  34. package/dist/lib/pi-adapter/interactive.js +4 -154
  35. package/dist/lib/pi-adapter/interactive.js.map +1 -1
  36. package/dist/lib/pi-adapter/runtime.js +25 -140
  37. package/dist/lib/pi-adapter/runtime.js.map +1 -1
  38. package/dist/lib/pi-adapter/stream.js +4 -154
  39. package/dist/lib/pi-adapter/stream.js.map +1 -1
  40. package/dist/lib/pi-adapter/theme.js.map +1 -1
  41. package/dist/lib/pod-chat-store.js +1 -1
  42. package/dist/lib/pod-chat-store.js.map +1 -1
  43. package/dist/lib/profile-identity.js +60 -16
  44. package/dist/lib/profile-identity.js.map +1 -1
  45. package/dist/lib/prompt.js.map +1 -1
  46. package/dist/lib/runtime-target.js +1 -1
  47. package/dist/lib/runtime-target.js.map +1 -1
  48. package/dist/lib/solid-auth.js.map +1 -1
  49. package/dist/lib/thread-utils.js.map +1 -1
  50. package/dist/lib/watch/archive.js +1 -1
  51. package/dist/lib/watch/archive.js.map +1 -1
  52. package/dist/lib/watch/auth.js +1 -1
  53. package/dist/lib/watch/auth.js.map +1 -1
  54. package/dist/lib/watch/codex-composer.js.map +1 -1
  55. package/dist/lib/watch/codex-footer.js.map +1 -1
  56. package/dist/lib/watch/codex-overlay.js.map +1 -1
  57. package/dist/lib/watch/codex-request-form.js +1 -1
  58. package/dist/lib/watch/codex-request-form.js.map +1 -1
  59. package/dist/lib/watch/codex-request-input.js.map +1 -1
  60. package/dist/lib/watch/display.js.map +1 -1
  61. package/dist/lib/watch/format.js.map +1 -1
  62. package/dist/lib/watch/hooks/claude.js +0 -4
  63. package/dist/lib/watch/hooks/claude.js.map +1 -1
  64. package/dist/lib/watch/hooks/codebuddy.js +0 -4
  65. package/dist/lib/watch/hooks/codebuddy.js.map +1 -1
  66. package/dist/lib/watch/hooks/codex.js +0 -4
  67. package/dist/lib/watch/hooks/codex.js.map +1 -1
  68. package/dist/lib/watch/hooks/index.js.map +1 -1
  69. package/dist/lib/watch/hooks/shared.js +1 -0
  70. package/dist/lib/watch/hooks/shared.js.map +1 -1
  71. package/dist/lib/watch/index.js.map +1 -1
  72. package/dist/lib/watch/pod-ai.js +37 -29
  73. package/dist/lib/watch/pod-ai.js.map +1 -1
  74. package/dist/lib/watch/pod-approval.js +216 -846
  75. package/dist/lib/watch/pod-approval.js.map +1 -1
  76. package/dist/lib/watch/pod-persistence.js +78 -184
  77. package/dist/lib/watch/pod-persistence.js.map +1 -1
  78. package/dist/lib/watch/runner.js +38 -243
  79. package/dist/lib/watch/runner.js.map +1 -1
  80. package/dist/lib/watch/types.js.map +1 -1
  81. package/dist/skills/drizzle-solid/SKILL.md +340 -0
  82. package/dist/skills/pod-storage/SKILL.md +60 -0
  83. package/dist/skills/solid-modeling/SKILL.md +274 -0
  84. package/dist/skills/xpod-componentsjs/SKILL.md +284 -0
  85. package/dist/watch-cli.js +34 -8
  86. package/dist/watch-cli.js.map +1 -1
  87. package/package.json +9 -3
  88. package/vendor/client/dist/client/index.d.ts +118 -0
  89. package/vendor/client/dist/client/index.js +260 -0
  90. package/vendor/client/dist/index.d.ts +1 -0
  91. package/vendor/client/dist/index.js +1 -0
  92. package/vendor/client/dist/watch/index.d.ts +226 -0
  93. package/vendor/client/dist/watch/index.js +1114 -0
  94. package/vendor/client/package.json +9 -0
  95. package/dist/lib/node-warning-filter.js +0 -34
  96. package/dist/lib/node-warning-filter.js.map +0 -1
  97. package/dist/lib/pi-adapter/pod-approval.js +0 -8
  98. package/dist/lib/pi-adapter/pod-approval.js.map +0 -1
  99. package/dist/lib/pi-adapter/pod-mirror-mapping.js +0 -189
  100. package/dist/lib/pi-adapter/pod-mirror-mapping.js.map +0 -1
  101. package/dist/lib/pi-adapter/pod-mirror.js +0 -334
  102. package/dist/lib/pi-adapter/pod-mirror.js.map +0 -1
  103. package/dist/lib/pi-adapter/pod-native.js +0 -478
  104. package/dist/lib/pi-adapter/pod-native.js.map +0 -1
  105. package/dist/lib/pi-adapter/session.js +0 -727
  106. package/dist/lib/pi-adapter/session.js.map +0 -1
  107. package/dist/lib/pod-data-session.js +0 -110
  108. package/dist/lib/pod-data-session.js.map +0 -1
  109. package/dist/lib/watch/secretary.js +0 -238
  110. package/dist/lib/watch/secretary.js.map +0 -1
  111. package/vendor/agent-runtime/dist/acp.d.ts +0 -27
  112. package/vendor/agent-runtime/dist/acp.js +0 -86
  113. package/vendor/agent-runtime/dist/companion-model.d.ts +0 -7
  114. package/vendor/agent-runtime/dist/companion-model.js +0 -12
  115. package/vendor/agent-runtime/dist/index.d.ts +0 -3
  116. package/vendor/agent-runtime/dist/index.js +0 -3
  117. package/vendor/agent-runtime/dist/turn-controller.d.ts +0 -69
  118. package/vendor/agent-runtime/dist/turn-controller.js +0 -129
  119. package/vendor/agent-runtime/package.json +0 -11
@@ -0,0 +1,260 @@
1
+ export const LINX_HOME_DIRNAME = '.linx';
2
+ export const LINX_CONFIG_FILE_NAME = 'config.json';
3
+ export const LINX_SECRETS_FILE_NAME = 'secrets.json';
4
+ export const LINX_ACCOUNT_SESSION_FILE_NAME = 'account.json';
5
+ export const LINX_CLOUD_IDENTITY_ORIGIN = 'https://id.undefineds.co';
6
+ export const LINX_CLOUD_API_ORIGIN = 'https://api.undefineds.co';
7
+ export const LINX_CLOUD_ACCOUNT_API_BASE_URL = `${LINX_CLOUD_IDENTITY_ORIGIN}/`;
8
+ export const LINX_CLOUD_RUNTIME_API_BASE_URL = `${LINX_CLOUD_API_ORIGIN}/v1`;
9
+ export const LINX_CLOUD_API_BASE_URL = LINX_CLOUD_ACCOUNT_API_BASE_URL;
10
+ export const LINX_CLOUD_IDENTITY_HOSTS = ['id.undefineds.co'];
11
+ function isRecord(value) {
12
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
13
+ }
14
+ function optionalString(value) {
15
+ return typeof value === 'string' ? value : undefined;
16
+ }
17
+ function parseStringRecord(value) {
18
+ if (!isRecord(value)) {
19
+ return {};
20
+ }
21
+ const entries = Object.entries(value)
22
+ .filter((entry) => typeof entry[1] === 'string');
23
+ return Object.fromEntries(entries);
24
+ }
25
+ function normalizeAuthType(value) {
26
+ return value === 'oidc_oauth' ? 'oidc_oauth' : 'client_credentials';
27
+ }
28
+ function trimTrailingSlash(url) {
29
+ return url.replace(/\/+$/, '');
30
+ }
31
+ function resolveHostname(url) {
32
+ try {
33
+ return new URL(url).hostname;
34
+ }
35
+ catch {
36
+ return '';
37
+ }
38
+ }
39
+ export function resolveLinxBaseUrl(url, fallbackBaseUrl = 'http://localhost:3000') {
40
+ const raw = typeof url === 'string' && url.trim() ? url.trim() : fallbackBaseUrl;
41
+ return raw.endsWith('/') ? raw : `${raw}/`;
42
+ }
43
+ export function resolveLinxRuntimeApiBaseUrl(url, fallbackBaseUrl = LINX_CLOUD_ACCOUNT_API_BASE_URL) {
44
+ const normalized = trimTrailingSlash(resolveLinxBaseUrl(url, fallbackBaseUrl));
45
+ return normalized.endsWith('/v1') ? normalized : `${normalized}/v1`;
46
+ }
47
+ export function resolveLinxCloudAccountBaseUrl(url) {
48
+ return resolveLinxBaseUrl(url, LINX_CLOUD_ACCOUNT_API_BASE_URL);
49
+ }
50
+ export function resolveLinxCloudRuntimeApiBaseUrl(url) {
51
+ return resolveLinxRuntimeApiBaseUrl(url, LINX_CLOUD_RUNTIME_API_BASE_URL);
52
+ }
53
+ export function resolveLinxCloudApiBaseUrl(url) {
54
+ return resolveLinxCloudAccountBaseUrl(url);
55
+ }
56
+ export function isLinxCloudIdentityBaseUrl(url) {
57
+ const normalized = resolveLinxBaseUrl(url, LINX_CLOUD_ACCOUNT_API_BASE_URL);
58
+ const hostname = resolveHostname(normalized);
59
+ return LINX_CLOUD_IDENTITY_HOSTS.includes(hostname);
60
+ }
61
+ export function resolveLinxRuntimeOriginForIssuerUrl(url) {
62
+ const normalized = trimTrailingSlash(resolveLinxBaseUrl(url, LINX_CLOUD_ACCOUNT_API_BASE_URL));
63
+ if (isLinxCloudIdentityBaseUrl(normalized)) {
64
+ return LINX_CLOUD_API_ORIGIN;
65
+ }
66
+ return normalized;
67
+ }
68
+ export function resolveLinxRuntimeApiBaseUrlForIssuerUrl(url) {
69
+ const runtimeOrigin = resolveLinxRuntimeOriginForIssuerUrl(url);
70
+ return resolveLinxRuntimeApiBaseUrl(runtimeOrigin, LINX_CLOUD_RUNTIME_API_BASE_URL);
71
+ }
72
+ export function resolveLinxPodUrl(webId) {
73
+ try {
74
+ const target = new URL(webId);
75
+ const pathParts = target.pathname.split('/').filter(Boolean);
76
+ return `${target.origin}/${pathParts[0] ?? ''}/`.replace(/\/+$/, '/');
77
+ }
78
+ catch {
79
+ return '';
80
+ }
81
+ }
82
+ export function resolveLinxPodBaseUrl(webId) {
83
+ return trimTrailingSlash(resolveLinxPodUrl(webId));
84
+ }
85
+ export function parseLinxClientConfig(raw) {
86
+ if (!isRecord(raw) || typeof raw.url !== 'string' || typeof raw.webId !== 'string') {
87
+ return null;
88
+ }
89
+ return {
90
+ url: raw.url,
91
+ webId: raw.webId,
92
+ authType: normalizeAuthType(raw.authType),
93
+ };
94
+ }
95
+ export function isLinxClientCredentialsSecrets(secrets) {
96
+ return 'clientId' in secrets && 'clientSecret' in secrets;
97
+ }
98
+ export function isLinxOidcOAuthSecrets(secrets) {
99
+ return 'oidcRefreshToken' in secrets && 'oidcAccessToken' in secrets && 'oidcExpiresAt' in secrets;
100
+ }
101
+ export function parseLinxClientSecrets(raw) {
102
+ if (!isRecord(raw)) {
103
+ return null;
104
+ }
105
+ if (typeof raw.clientId === 'string' && typeof raw.clientSecret === 'string') {
106
+ return {
107
+ clientId: raw.clientId,
108
+ clientSecret: raw.clientSecret,
109
+ };
110
+ }
111
+ if (typeof raw.oidcRefreshToken === 'string'
112
+ && typeof raw.oidcAccessToken === 'string'
113
+ && typeof raw.oidcExpiresAt === 'string') {
114
+ return {
115
+ oidcRefreshToken: raw.oidcRefreshToken,
116
+ oidcAccessToken: raw.oidcAccessToken,
117
+ oidcExpiresAt: raw.oidcExpiresAt,
118
+ };
119
+ }
120
+ return null;
121
+ }
122
+ export function parseLinxAccountData(raw) {
123
+ if (!isRecord(raw)) {
124
+ return null;
125
+ }
126
+ const controls = isRecord(raw.controls) ? raw.controls : {};
127
+ const accountControls = isRecord(controls.account) ? controls.account : controls;
128
+ return {
129
+ controls: {
130
+ pod: optionalString(accountControls.pod),
131
+ clientCredentials: optionalString(accountControls.clientCredentials),
132
+ },
133
+ pods: parseStringRecord(raw.pods),
134
+ webIds: parseStringRecord(raw.webIds),
135
+ clientCredentials: parseStringRecord(raw.clientCredentials),
136
+ };
137
+ }
138
+ export function parseLinxClientCredential(raw) {
139
+ if (!isRecord(raw) || typeof raw.id !== 'string') {
140
+ return null;
141
+ }
142
+ return {
143
+ id: raw.id,
144
+ label: optionalString(raw.label),
145
+ secret: optionalString(raw.secret),
146
+ webId: optionalString(raw.webId),
147
+ };
148
+ }
149
+ export function parseAccountSession(raw) {
150
+ if (!isRecord(raw)
151
+ || typeof raw.url !== 'string'
152
+ || typeof raw.email !== 'string'
153
+ || typeof raw.token !== 'string'
154
+ || typeof raw.createdAt !== 'string') {
155
+ return null;
156
+ }
157
+ return {
158
+ url: raw.url,
159
+ email: raw.email,
160
+ token: raw.token,
161
+ webId: optionalString(raw.webId),
162
+ podUrl: optionalString(raw.podUrl),
163
+ createdAt: raw.createdAt,
164
+ };
165
+ }
166
+ export function selectLinxAccountWebId(account, preferredWebId) {
167
+ if (typeof preferredWebId === 'string' && preferredWebId.trim()) {
168
+ return preferredWebId.trim();
169
+ }
170
+ if (!account) {
171
+ return null;
172
+ }
173
+ return Object.keys(account.webIds)[0] ?? null;
174
+ }
175
+ export function hasMatchingLinxStoredCredentials(credentials, baseUrl, webId) {
176
+ return credentials?.url === baseUrl && credentials?.webId === webId;
177
+ }
178
+ export function resolveLinxCredentialBootstrapStatus(input) {
179
+ if (input.reusedExistingCredentials) {
180
+ return 'reused';
181
+ }
182
+ return input.hadMatchingStoredCredentials ? 'recreated' : 'created';
183
+ }
184
+ export function listLinxWhoAmIFields(session, options = {}) {
185
+ const fields = [
186
+ { key: 'email', value: session.email },
187
+ { key: 'server', value: session.url },
188
+ ];
189
+ if (session.webId) {
190
+ fields.push({ key: 'webId', value: session.webId });
191
+ }
192
+ if (options.verbose && session.podUrl) {
193
+ fields.push({ key: 'pod', value: session.podUrl });
194
+ }
195
+ fields.push({ key: 'session-created-at', value: session.createdAt });
196
+ return fields;
197
+ }
198
+ export async function performLinxPasswordLogin(input, deps) {
199
+ const baseUrl = resolveLinxBaseUrl(input.baseUrl, input.fallbackBaseUrl);
200
+ if (!(await deps.checkServer(baseUrl))) {
201
+ throw new Error(`Cannot reach server at ${baseUrl}`);
202
+ }
203
+ const token = await deps.login(input.email, input.password, baseUrl);
204
+ if (!token) {
205
+ throw new Error('Login failed.');
206
+ }
207
+ const account = await deps.getAccountData(token, baseUrl);
208
+ if (!account) {
209
+ throw new Error('Failed to load account data after login.');
210
+ }
211
+ const webId = selectLinxAccountWebId(account, input.requestedWebId);
212
+ if (!webId) {
213
+ throw new Error('No WebID found. Pass --web-id explicitly.');
214
+ }
215
+ const hadMatchingStoredCredentials = hasMatchingLinxStoredCredentials(input.existingCredentials, baseUrl, webId);
216
+ const existingCredentialsValid = hadMatchingStoredCredentials && input.existingCredentials?.authType === 'client_credentials'
217
+ ? await deps.validateClientCredentials?.(input.existingCredentials)
218
+ : false;
219
+ const reusedExistingCredentials = hadMatchingStoredCredentials
220
+ && input.existingCredentials?.authType === 'client_credentials'
221
+ && existingCredentialsValid === true;
222
+ const credentialStatus = resolveLinxCredentialBootstrapStatus({
223
+ reusedExistingCredentials,
224
+ hadMatchingStoredCredentials,
225
+ });
226
+ let credentialsToSave;
227
+ if (!reusedExistingCredentials) {
228
+ if (!account.controls.clientCredentials) {
229
+ throw new Error('Cannot find client credentials endpoint.');
230
+ }
231
+ const credential = await deps.createClientCredentials(token, account.controls.clientCredentials, webId, input.credentialName ?? undefined);
232
+ if (!credential?.id || !credential.secret) {
233
+ throw new Error('Failed to create local client credentials.');
234
+ }
235
+ credentialsToSave = {
236
+ url: baseUrl,
237
+ webId,
238
+ authType: 'client_credentials',
239
+ secrets: {
240
+ clientId: credential.id,
241
+ clientSecret: credential.secret,
242
+ },
243
+ };
244
+ }
245
+ return {
246
+ baseUrl,
247
+ webId,
248
+ account,
249
+ credentialStatus,
250
+ ...(credentialsToSave ? { credentialsToSave } : {}),
251
+ session: {
252
+ url: baseUrl,
253
+ email: input.email,
254
+ token,
255
+ webId,
256
+ podUrl: resolveLinxPodUrl(webId),
257
+ createdAt: (input.now ?? new Date()).toISOString(),
258
+ },
259
+ };
260
+ }
@@ -0,0 +1 @@
1
+ export * from './client/index.js';
@@ -0,0 +1 @@
1
+ export * from './client/index.js';
@@ -0,0 +1,226 @@
1
+ export type WatchBackend = 'codex' | 'claude' | 'codebuddy';
2
+ export type WatchMode = 'manual' | 'smart' | 'auto';
3
+ export type WatchSessionStatus = 'running' | 'completed' | 'failed';
4
+ export type WatchOutputStream = 'stdout' | 'stderr' | 'system';
5
+ export type WatchCredentialSource = 'auto' | 'local' | 'cloud';
6
+ export type WatchResolvedCredentialSource = 'local' | 'cloud';
7
+ export type WatchApprovalSource = 'local' | 'remote' | 'hybrid';
8
+ export type WatchRuntime = 'local';
9
+ export type WatchTransport = 'native' | 'acp';
10
+ export type WatchAuthState = 'authenticated' | 'unauthenticated' | 'unknown';
11
+ export interface WatchAuthStatus {
12
+ state: WatchAuthState;
13
+ message?: string;
14
+ }
15
+ export interface WatchAuthFailure {
16
+ message: string;
17
+ }
18
+ export type WatchCloudCredentialProbeStatus = 'available' | 'unavailable' | 'error';
19
+ export interface WatchCloudCredentialProbe {
20
+ status: WatchCloudCredentialProbeStatus;
21
+ message?: string;
22
+ }
23
+ export interface WatchCredentialSourceResolution {
24
+ requestedSource: WatchCredentialSource;
25
+ resolvedSource?: WatchResolvedCredentialSource;
26
+ authStatus: WatchAuthStatus;
27
+ error?: string;
28
+ }
29
+ export interface WatchSessionRecord {
30
+ id: string;
31
+ backend: WatchBackend;
32
+ runtime: WatchRuntime;
33
+ transport?: WatchTransport;
34
+ mode: WatchMode;
35
+ cwd: string;
36
+ model?: string;
37
+ prompt?: string;
38
+ passthroughArgs: string[];
39
+ credentialSource: WatchCredentialSource;
40
+ resolvedCredentialSource?: WatchResolvedCredentialSource;
41
+ approvalSource?: WatchApprovalSource;
42
+ command: string;
43
+ args: string[];
44
+ status: WatchSessionStatus;
45
+ startedAt: string;
46
+ endedAt?: string;
47
+ exitCode?: number | null;
48
+ signal?: string | null;
49
+ error?: string;
50
+ backendSessionId?: string;
51
+ archiveDir: string;
52
+ eventsFile: string;
53
+ }
54
+ export type WatchApprovalRequestKind = 'command-approval' | 'file-change-approval' | 'permissions-approval' | 'codex-approval';
55
+ export type WatchInteractionRequestKind = WatchApprovalRequestKind | 'user-input';
56
+ export type WatchApprovalDecision = 'accept' | 'accept_for_session' | 'decline' | 'cancel';
57
+ interface WatchInteractionRequestBase {
58
+ kind: WatchInteractionRequestKind;
59
+ message: string;
60
+ raw?: unknown;
61
+ }
62
+ export interface WatchCommandApprovalRequest extends WatchInteractionRequestBase {
63
+ kind: 'command-approval';
64
+ command?: string;
65
+ cwd?: string;
66
+ }
67
+ export interface WatchFileChangeApprovalRequest extends WatchInteractionRequestBase {
68
+ kind: 'file-change-approval';
69
+ reason?: string;
70
+ }
71
+ export interface WatchPermissionsApprovalRequest extends WatchInteractionRequestBase {
72
+ kind: 'permissions-approval';
73
+ permissions: Record<string, unknown>;
74
+ }
75
+ export interface WatchCodexApprovalRequest extends WatchInteractionRequestBase {
76
+ kind: 'codex-approval';
77
+ }
78
+ export interface WatchUserInputOption {
79
+ label: string;
80
+ description?: string;
81
+ }
82
+ export interface WatchUserInputQuestion {
83
+ id: string;
84
+ header: string;
85
+ question: string;
86
+ options: WatchUserInputOption[];
87
+ }
88
+ export interface WatchUserInputRequest extends WatchInteractionRequestBase {
89
+ kind: 'user-input';
90
+ questions: WatchUserInputQuestion[];
91
+ }
92
+ export type WatchApprovalRequest = WatchCommandApprovalRequest | WatchFileChangeApprovalRequest | WatchPermissionsApprovalRequest | WatchCodexApprovalRequest;
93
+ export type WatchInteractionRequest = WatchApprovalRequest | WatchUserInputRequest;
94
+ export interface WatchUserInputAnswerRecord {
95
+ answers: string[];
96
+ }
97
+ export type WatchUserInputAnswers = Record<string, WatchUserInputAnswerRecord>;
98
+ export interface WatchToolCallEvent {
99
+ type: 'tool.call';
100
+ name: string;
101
+ arguments?: Record<string, unknown>;
102
+ raw?: unknown;
103
+ }
104
+ export interface WatchApprovalRequiredEvent {
105
+ type: 'approval.required';
106
+ message: string;
107
+ request?: WatchApprovalRequest;
108
+ raw?: unknown;
109
+ }
110
+ export interface WatchInputRequiredEvent {
111
+ type: 'input.required';
112
+ message: string;
113
+ request: WatchUserInputRequest;
114
+ raw?: unknown;
115
+ }
116
+ export interface WatchAssistantDeltaEvent {
117
+ type: 'assistant.delta';
118
+ text: string;
119
+ raw?: unknown;
120
+ }
121
+ export interface WatchAssistantDoneEvent {
122
+ type: 'assistant.done';
123
+ text?: string;
124
+ raw?: unknown;
125
+ }
126
+ export interface WatchNoteEvent {
127
+ type: 'session.note';
128
+ message: string;
129
+ raw?: unknown;
130
+ }
131
+ export type WatchNormalizedEvent = WatchToolCallEvent | WatchApprovalRequiredEvent | WatchInputRequiredEvent | WatchAssistantDeltaEvent | WatchAssistantDoneEvent | WatchNoteEvent;
132
+ export interface WatchEventLogEntry {
133
+ timestamp: string;
134
+ stream: WatchOutputStream;
135
+ line: string;
136
+ events: WatchNormalizedEvent[];
137
+ }
138
+ export interface WatchThreadMetadata extends Record<string, unknown> {
139
+ kind: 'watch';
140
+ delegatedTo: 'secretary';
141
+ sessionId: string;
142
+ backend: WatchBackend;
143
+ runtime: WatchRuntime;
144
+ transport?: WatchTransport;
145
+ mode: WatchMode;
146
+ cwd: string;
147
+ model?: string;
148
+ credentialSource: WatchCredentialSource;
149
+ resolvedCredentialSource?: WatchResolvedCredentialSource;
150
+ approvalSource?: WatchApprovalSource;
151
+ status: WatchSessionStatus;
152
+ backendSessionId?: string;
153
+ }
154
+ export type WatchTranscriptMessageRole = 'user' | 'assistant' | 'system';
155
+ export interface WatchTranscriptMessage {
156
+ role: WatchTranscriptMessageRole;
157
+ content: string;
158
+ createdAt: string;
159
+ }
160
+ export interface CreateWatchSessionIdOptions {
161
+ now?: Date;
162
+ randomId?: string;
163
+ }
164
+ export interface WatchArchiveRelativePaths {
165
+ sessionDir: string;
166
+ sessionFile: string;
167
+ eventsFile: string;
168
+ }
169
+ export declare const WATCH_HOME_DIRNAME = "watch";
170
+ export declare const WATCH_SESSIONS_DIRNAME = "sessions";
171
+ export declare const WATCH_SESSION_FILE_NAME = "session.json";
172
+ export declare const WATCH_EVENTS_FILE_NAME = "events.jsonl";
173
+ export declare function normalizeWatchUserInputQuestion(value: unknown, fallbackId?: string): WatchUserInputQuestion | null;
174
+ export declare function resolveWatchQuestionAnswer(question: WatchUserInputQuestion, answer: string): string[];
175
+ export declare function createWatchSessionId(options?: CreateWatchSessionIdOptions): string;
176
+ export declare function normalizeWatchCredentialSource(source?: WatchCredentialSource | null): WatchCredentialSource;
177
+ export declare function shouldAttemptCloudCredentialProbe(requestedSource: WatchCredentialSource, localAuthStatus: WatchAuthStatus): boolean;
178
+ export declare function formatWatchAutoFallbackMessage(localMessage: string, detail: string): string;
179
+ export declare function resolveWatchCredentialSourceResolution(input: {
180
+ requestedSource?: WatchCredentialSource | null;
181
+ localAuthStatus: WatchAuthStatus;
182
+ cloudCredentialProbe?: WatchCloudCredentialProbe;
183
+ defaultLocalMessage?: string;
184
+ }): WatchCredentialSourceResolution;
185
+ export declare function resolveWatchAutoApprovalDecision(input: {
186
+ mode: WatchMode;
187
+ request: WatchApprovalRequest;
188
+ }): WatchApprovalDecision | null;
189
+ export declare function getWatchAuthLoginCommand(backend: WatchBackend): string | null;
190
+ export declare function formatWatchBackendAuthMessage(backend: WatchBackend, detail?: string): string;
191
+ export declare function looksLikeWatchAuthFailureText(text: string): boolean;
192
+ export declare function parseWatchClaudeAuthStatus(stdout: string): WatchAuthStatus;
193
+ export declare function detectWatchAuthFailure(backend: WatchBackend, line: string): WatchAuthFailure | null;
194
+ export declare function parseWatchJsonLine(line: string): Record<string, unknown> | null;
195
+ export declare function extractWatchSessionIdFromJsonLine(line: string): string | undefined;
196
+ export declare function isTrustedWatchCommand(command: string | null | undefined): boolean;
197
+ export declare function normalizeCodexAppServerInteractionRequest(message: Record<string, unknown>): WatchInteractionRequest | null;
198
+ export declare function resolveWatchInteractionAutoResponse(input: {
199
+ mode: WatchMode;
200
+ request: WatchInteractionRequest;
201
+ }): unknown | null;
202
+ export declare function buildCodexApprovalResponse(request: WatchApprovalRequest, decision: WatchApprovalDecision): unknown;
203
+ export declare function buildCodexUserInputResponse(answers: WatchUserInputAnswers): {
204
+ answers: WatchUserInputAnswers;
205
+ };
206
+ export declare function buildWatchUserInputResponse(answers: WatchUserInputAnswers): {
207
+ answers: WatchUserInputAnswers;
208
+ };
209
+ export declare function normalizeAcpInteractionRequest(message: Record<string, unknown>): WatchInteractionRequest | null;
210
+ export declare function normalizeAcpRequest(message: Record<string, unknown>): WatchNormalizedEvent[];
211
+ export declare function normalizeAcpSessionNotification(message: Record<string, unknown>): WatchNormalizedEvent[];
212
+ export declare function buildAcpPermissionResponse(request: WatchApprovalRequest, decision: WatchApprovalDecision): {
213
+ outcome: {
214
+ outcome: 'selected';
215
+ optionId: string;
216
+ } | {
217
+ outcome: 'cancelled';
218
+ };
219
+ };
220
+ export declare function parseWatchJsonProtocolLine(line: string): WatchNormalizedEvent[];
221
+ export declare function normalizeCodexAppServerNotification(message: Record<string, unknown>): WatchNormalizedEvent[];
222
+ export declare function normalizeCodexAppServerRequest(message: Record<string, unknown>): WatchNormalizedEvent[];
223
+ export declare function getWatchArchiveRelativePaths(sessionId: string): WatchArchiveRelativePaths;
224
+ export declare function buildWatchThreadMetadata(record: WatchSessionRecord): WatchThreadMetadata;
225
+ export declare function buildWatchTranscriptMessages(entries: WatchEventLogEntry[]): WatchTranscriptMessage[];
226
+ export {};