@borgee/agents-host 0.2.97 → 0.2.110

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 (104) hide show
  1. package/README.md +77 -5
  2. package/dist/agents-host.d.ts +16 -0
  3. package/dist/agents-host.js +608 -82
  4. package/dist/catalog-worker.js +21 -0
  5. package/dist/catalog-worker.js.map +7 -0
  6. package/dist/chat/chat-control-plane.d.ts +19 -4
  7. package/dist/chat/normalized-input.d.ts +9 -0
  8. package/dist/chat/normalized-input.js +24 -0
  9. package/dist/chat/sdk-chat-control-plane.d.ts +46 -6
  10. package/dist/chat/sdk-chat-control-plane.js +169 -6
  11. package/dist/cli-args.d.ts +1 -1
  12. package/dist/cli-args.js +13 -4
  13. package/dist/config.d.ts +3 -1
  14. package/dist/config.js +25 -0
  15. package/dist/context/injection.d.ts +16 -0
  16. package/dist/context/injection.js +37 -21
  17. package/dist/context/prompt.d.ts +12 -0
  18. package/dist/context/prompt.js +25 -0
  19. package/dist/context/skill-manual.js +1 -1
  20. package/dist/context/turn-preparation.d.ts +2 -1
  21. package/dist/context/turn-preparation.js +15 -0
  22. package/dist/execution-telemetry.d.ts +96 -0
  23. package/dist/execution-telemetry.js +583 -0
  24. package/dist/gateway/channel-file-workspace.d.ts +15 -0
  25. package/dist/gateway/channel-file-workspace.js +130 -0
  26. package/dist/gateway/localhost-gateway.js +167 -2
  27. package/dist/hosted-turn-content.js +3 -2
  28. package/dist/local-config.js +34 -1
  29. package/dist/managed-daemon.js +15 -0
  30. package/dist/native-environment.d.ts +2 -0
  31. package/dist/native-environment.js +9 -0
  32. package/dist/native-protocol-types/codec.d.ts +49 -0
  33. package/dist/native-protocol-types/commands.d.ts +71 -0
  34. package/dist/native-protocol-types/compatibility.d.ts +5 -0
  35. package/dist/native-protocol-types/cursor.d.ts +7 -0
  36. package/dist/native-protocol-types/envelope.d.ts +1105 -0
  37. package/dist/native-protocol-types/file-changes.d.ts +20 -0
  38. package/dist/native-protocol-types/history.d.ts +487 -0
  39. package/dist/native-protocol-types/index.d.ts +18 -0
  40. package/dist/native-protocol-types/interactions.d.ts +619 -0
  41. package/dist/native-protocol-types/messages.d.ts +2482 -0
  42. package/dist/native-protocol-types/public-validation.d.ts +10 -0
  43. package/dist/native-protocol-types/remote-host-uplink.d.ts +67 -0
  44. package/dist/native-protocol-types/resources.d.ts +126 -0
  45. package/dist/native-protocol-types/session-settings.d.ts +22 -0
  46. package/dist/native-protocol-types/snapshot.d.ts +575 -0
  47. package/dist/native-protocol-types/timeline.d.ts +1503 -0
  48. package/dist/native-protocol-types/tool-result.d.ts +26 -0
  49. package/dist/native-protocol-types/uplink.d.ts +56 -0
  50. package/dist/native-protocol-types/version.d.ts +5 -0
  51. package/dist/native-provider-types/commands.d.ts +51 -0
  52. package/dist/native-provider-types/control.d.ts +192 -0
  53. package/dist/native-provider-types/file-changes.d.ts +9 -0
  54. package/dist/native-provider-types/index.d.ts +8 -0
  55. package/dist/native-provider-types/interactions.d.ts +7 -0
  56. package/dist/native-provider-types/observation.d.ts +209 -0
  57. package/dist/native-provider-types/provider.d.ts +124 -0
  58. package/dist/native-provider-types/session-settings.d.ts +17 -0
  59. package/dist/native-provider-types/testing.d.ts +27 -0
  60. package/dist/native-provider-types/tool-result.d.ts +21 -0
  61. package/dist/native-providers.d.ts +21 -0
  62. package/dist/native-providers.js +18402 -0
  63. package/dist/native-providers.js.map +7 -0
  64. package/dist/plugin-sdk.js +10713 -229
  65. package/dist/plugin-sdk.js.map +4 -4
  66. package/dist/policy/copilot-permission.js +1 -8
  67. package/dist/policy/gateway-authorization.d.ts +1 -1
  68. package/dist/policy/gateway-authorization.js +22 -2
  69. package/dist/providers/claude/adapter.js +1 -0
  70. package/dist/providers/claude/cli-client.js +4 -0
  71. package/dist/providers/codex/adapter.js +1 -0
  72. package/dist/providers/codex/cli-client.js +5 -0
  73. package/dist/providers/copilot/adapter.js +4 -0
  74. package/dist/providers/copilot/cli-client.js +11 -1
  75. package/dist/providers/copilot/sdk-session.d.ts +12 -3
  76. package/dist/providers/copilot/sdk-session.js +230 -6
  77. package/dist/providers/create-provider.js +24 -0
  78. package/dist/providers/normalized/adapter.d.ts +107 -0
  79. package/dist/providers/normalized/adapter.js +1650 -0
  80. package/dist/providers/normalized/control-policy.d.ts +5 -0
  81. package/dist/providers/normalized/control-policy.js +12 -0
  82. package/dist/providers/normalized/interactions.d.ts +3 -0
  83. package/dist/providers/normalized/interactions.js +39 -0
  84. package/dist/providers/normalized/legacy-input-ownership.d.ts +34 -0
  85. package/dist/providers/normalized/legacy-input-ownership.js +123 -0
  86. package/dist/providers/normalized/session-management.d.ts +67 -0
  87. package/dist/providers/normalized/session-management.js +334 -0
  88. package/dist/providers/normalized/session-ownership.d.ts +3 -0
  89. package/dist/providers/normalized/session-ownership.js +90 -0
  90. package/dist/providers/prompt-usage.d.ts +8 -0
  91. package/dist/providers/prompt-usage.js +52 -0
  92. package/dist/providers/provider-adapter.d.ts +43 -1
  93. package/dist/providers/provider-adapter.js +8 -0
  94. package/dist/state-paths.d.ts +2 -0
  95. package/dist/state-paths.js +6 -0
  96. package/dist/types.d.ts +66 -0
  97. package/dist/typing-lease.d.ts +14 -0
  98. package/dist/typing-lease.js +31 -0
  99. package/dist/vendor/agent-provider-codex/LICENSE +211 -0
  100. package/dist/vendor/agent-provider-codex/NOTICE +13 -0
  101. package/package.json +22 -13
  102. package/skills/borgee-agent/SKILL.md +12 -4
  103. package/skills/borgee-agent/scripts/borgee-agent.mjs +110 -0
  104. package/skills/borgee-agent/scripts/borgee-agent.py +116 -0
@@ -0,0 +1,90 @@
1
+ import { createRequire } from 'node:module';
2
+ import { mkdir, readdir, readFile } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { resolveConnectionsStatePath } from '../../state-paths.js';
5
+ /** Reads ownership evidence without initializing, migrating, or writing default stores. */
6
+ export async function readProtectedCodexSessions(stateRoot) {
7
+ const ids = new Set();
8
+ const names = async (path) => {
9
+ try {
10
+ return await readdir(path);
11
+ }
12
+ catch (error) {
13
+ if (error.code === 'ENOENT')
14
+ return [];
15
+ throw error;
16
+ }
17
+ };
18
+ const normalized = join(stateRoot, 'native-sessions', 'codex');
19
+ for (const name of await names(normalized)) {
20
+ if (!name.endsWith('.json'))
21
+ continue;
22
+ const records = JSON.parse(await readFile(join(normalized, name), 'utf8'));
23
+ if (!records || typeof records !== 'object' || Array.isArray(records))
24
+ throw new Error('session_ownership_unavailable');
25
+ for (const value of Object.values(records)) {
26
+ const entry = typeof value === 'string' ? JSON.parse(value) : undefined;
27
+ if (!entry?.handle || entry.handle.providerId !== 'codex' || typeof entry.handle.sessionId !== 'string')
28
+ throw new Error('session_ownership_unavailable');
29
+ ids.add(entry.handle.sessionId);
30
+ }
31
+ }
32
+ const rootNames = await names(stateRoot);
33
+ for (const name of rootNames) {
34
+ if (!/^codex-channel-sessions-.*\.json$/.test(name))
35
+ continue;
36
+ const records = JSON.parse(await readFile(join(stateRoot, name), 'utf8'));
37
+ if (!records || typeof records !== 'object' || Array.isArray(records))
38
+ throw new Error('session_ownership_unavailable');
39
+ for (const value of Object.values(records)) {
40
+ if (typeof value !== 'string' || !value)
41
+ throw new Error('session_ownership_unavailable');
42
+ ids.add(value);
43
+ }
44
+ }
45
+ if (rootNames.includes('connections-state.sqlite')) {
46
+ const { DatabaseSync } = createRequire(import.meta.url)('node:sqlite');
47
+ const database = new DatabaseSync(resolveConnectionsStatePath(stateRoot), { readOnly: true });
48
+ try {
49
+ const exists = database.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'provider_channel_sessions'").get();
50
+ if (exists)
51
+ for (const row of database.prepare("SELECT session_id FROM provider_channel_sessions WHERE provider = 'codex'").all()) {
52
+ if (typeof row.session_id !== 'string' || !row.session_id)
53
+ throw new Error('session_ownership_unavailable');
54
+ ids.add(row.session_id);
55
+ }
56
+ }
57
+ finally {
58
+ database.close();
59
+ }
60
+ }
61
+ return ids;
62
+ }
63
+ export function createSessionOwnershipLock(directory) {
64
+ return async (work) => {
65
+ await mkdir(directory, { recursive: true, mode: 0o700 });
66
+ const { DatabaseSync } = createRequire(import.meta.url)('node:sqlite');
67
+ const database = new DatabaseSync(join(directory, '.admission-lock.sqlite'));
68
+ try {
69
+ database.exec('PRAGMA busy_timeout = 0');
70
+ try {
71
+ database.exec('BEGIN IMMEDIATE');
72
+ }
73
+ catch (error) {
74
+ if (error.errcode === 5)
75
+ throw new Error('session_ownership_busy');
76
+ throw error;
77
+ }
78
+ // The OS releases the transaction lock on process exit; never unlink its shared file.
79
+ try {
80
+ return await work();
81
+ }
82
+ finally {
83
+ database.exec('ROLLBACK');
84
+ }
85
+ }
86
+ finally {
87
+ database.close();
88
+ }
89
+ };
90
+ }
@@ -0,0 +1,8 @@
1
+ import type { ProviderTokenUsage } from '../types.js';
2
+ /**
3
+ * ACP prompt usage defines input and cached tokens as separate counters.
4
+ * Provider totals, context occupancy, and thought tokens have no equivalent in
5
+ * the execution ledger and are deliberately not projected.
6
+ */
7
+ export declare function normalizeAcpPromptUsage(value: unknown): ProviderTokenUsage | undefined;
8
+ export declare function normalizeProviderCallUsage(value: unknown): ProviderTokenUsage | undefined;
@@ -0,0 +1,52 @@
1
+ function tokenCount(value, optional = false) {
2
+ if (value == null && optional)
3
+ return 0;
4
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0)
5
+ return undefined;
6
+ return value;
7
+ }
8
+ /**
9
+ * ACP prompt usage defines input and cached tokens as separate counters.
10
+ * Provider totals, context occupancy, and thought tokens have no equivalent in
11
+ * the execution ledger and are deliberately not projected.
12
+ */
13
+ export function normalizeAcpPromptUsage(value) {
14
+ if (!value || typeof value !== 'object')
15
+ return undefined;
16
+ const usage = value;
17
+ const inputTokens = tokenCount(usage.inputTokens);
18
+ const outputTokens = tokenCount(usage.outputTokens);
19
+ const cacheReadTokens = tokenCount(usage.cachedReadTokens, true);
20
+ const cacheWriteTokens = tokenCount(usage.cachedWriteTokens, true);
21
+ if (inputTokens === undefined ||
22
+ outputTokens === undefined ||
23
+ cacheReadTokens === undefined ||
24
+ cacheWriteTokens === undefined) {
25
+ return undefined;
26
+ }
27
+ return { inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens };
28
+ }
29
+ export function normalizeProviderCallUsage(value) {
30
+ if (!value || typeof value !== 'object')
31
+ return undefined;
32
+ const usage = value;
33
+ const reported = [
34
+ usage.inputTokens,
35
+ usage.outputTokens,
36
+ usage.cacheReadTokens,
37
+ usage.cacheWriteTokens,
38
+ ];
39
+ if (reported.every((tokens) => tokens == null))
40
+ return undefined;
41
+ const inputTokens = tokenCount(usage.inputTokens, true);
42
+ const outputTokens = tokenCount(usage.outputTokens, true);
43
+ const cacheReadTokens = tokenCount(usage.cacheReadTokens, true);
44
+ const cacheWriteTokens = tokenCount(usage.cacheWriteTokens, true);
45
+ if (inputTokens === undefined ||
46
+ outputTokens === undefined ||
47
+ cacheReadTokens === undefined ||
48
+ cacheWriteTokens === undefined) {
49
+ return undefined;
50
+ }
51
+ return { inputTokens, outputTokens, cacheReadTokens, cacheWriteTokens };
52
+ }
@@ -1,3 +1,5 @@
1
+ import type { SessionControlRequest, SessionControlResponse } from '../plugin-sdk.js';
2
+ import type { AgentInteractionResponse } from '../native-providers.js';
1
3
  import type { ProviderAutonomousReply, ProviderGenerateOptions, ProviderInput, ProviderReply } from '../types.js';
2
4
  export type ProviderImageInputSupport = 'supported' | 'metadata-only' | 'not-supported';
3
5
  export type ProviderImageTransportSupport = 'supported' | 'not-supported';
@@ -49,13 +51,53 @@ export declare function createHostedProviderCapabilities(params: {
49
51
  sharedHostFallback?: SharedHostAttachmentMetadataFallbackCapability;
50
52
  }): ProviderCapabilities;
51
53
  export declare const TEXT_ONLY_HOSTED_PROVIDER_CAPABILITIES: ProviderCapabilities;
54
+ export declare class ProviderInputRejectedError extends Error {
55
+ readonly publicReplyText: string;
56
+ constructor(publicReplyText: string);
57
+ }
52
58
  export declare class ProviderTurnCancelledError extends Error {
53
59
  readonly publicReplyText?: string;
54
60
  constructor(message?: string, options?: {
55
61
  publicReplyText?: string;
56
62
  });
57
63
  }
64
+ export interface ProviderSessionControlContext {
65
+ signal: AbortSignal;
66
+ connectionSignal?: AbortSignal;
67
+ execution?: ProviderGenerateOptions;
68
+ isConnectionCurrent?(): boolean;
69
+ activateExecution?(isCurrent: () => boolean): ProviderGenerateOptions | Promise<ProviderGenerateOptions>;
70
+ onCompletion?(completion: Promise<ProviderReply | undefined>): void;
71
+ }
72
+ export interface ProviderSessionControlResult {
73
+ response: SessionControlResponse;
74
+ completion?: Promise<ProviderReply | undefined>;
75
+ }
58
76
  export interface ProviderAdapter {
77
+ readonly supportsSessionManagement?: boolean;
78
+ describeSessionManagement?(): Promise<import('../plugin-sdk.js').SessionManagementAvailability>;
79
+ manageSession?(request: import('../plugin-sdk.js').SessionManagementRequest, context: import('../plugin-sdk.js').ServerRequestContext): Promise<unknown>;
80
+ listSessions?(request: import('../plugin-sdk.js').SessionDirectoryRequest, context: import('../plugin-sdk.js').ServerRequestContext): import('../plugin-sdk.js').SessionDirectoryResult;
81
+ describeSession?(request: import('../plugin-sdk.js').SessionDescriptionRequest, context: import('../plugin-sdk.js').ServerRequestContext): import('../plugin-sdk.js').SessionControlTarget | undefined;
82
+ observeSession?(request: import('../plugin-sdk.js').SessionObservationRequest, context: import('../plugin-sdk.js').ServerRequestContext): Promise<import('../plugin-sdk.js').SessionObservationResult>;
83
+ readonly supportsSessionInput?: boolean;
84
+ readonly sessionInputOperations?: readonly ('start_turn' | 'steer' | 'next_turn')[];
85
+ controlSession?(request: SessionControlRequest, context: ProviderSessionControlContext): Promise<ProviderSessionControlResult>;
86
+ readonly outputMode?: 'legacy' | 'normalized';
87
+ syncNormalizedActivity?(channelId: string, bindingId?: string): boolean;
88
+ setSessionPublication?(publication: {
89
+ supported(): boolean;
90
+ publish(channelId: string, activity: import('../plugin-sdk.js').AgentActivity): boolean;
91
+ }): void;
92
+ publishSessionBindings?(): void;
93
+ respondInteraction?(input: {
94
+ channelId: string;
95
+ taskId?: string;
96
+ agentId: string;
97
+ requestId: string;
98
+ response: AgentInteractionResponse;
99
+ binding?: Pick<SessionControlRequest, 'binding_id' | 'native_session_id' | 'connection_generation'>;
100
+ }, context?: import('../plugin-sdk.js').ServerRequestContext): Promise<AgentInteractionResponse>;
59
101
  readonly capabilities: ProviderCapabilities;
60
102
  generateReply(input: ProviderInput, options?: ProviderGenerateOptions): Promise<ProviderReply>;
61
103
  onAutonomousReply?(handler: ((reply: ProviderAutonomousReply) => void) | undefined): void;
@@ -64,7 +106,7 @@ export interface ProviderAdapter {
64
106
  }>;
65
107
  interruptTurn?(channelId: string): Promise<boolean>;
66
108
  cancelSession?(channelId: string): Promise<boolean>;
67
- cancelTurn?(channelId: string): Promise<boolean>;
109
+ cancelTurn?(channelId: string, binding?: Pick<SessionControlRequest, 'binding_id' | 'native_session_id' | 'connection_generation'>, context?: import('../plugin-sdk.js').ServerRequestContext): Promise<boolean>;
68
110
  cancelBackgroundRun?(channelId: string, providerRunId: string): Promise<boolean>;
69
111
  dispose?(): Promise<void>;
70
112
  }
@@ -59,6 +59,14 @@ export const TEXT_ONLY_HOSTED_PROVIDER_CAPABILITIES = createHostedProviderCapabi
59
59
  targetedCancellation: 'not-supported',
60
60
  },
61
61
  });
62
+ export class ProviderInputRejectedError extends Error {
63
+ publicReplyText;
64
+ constructor(publicReplyText) {
65
+ super(publicReplyText);
66
+ this.publicReplyText = publicReplyText;
67
+ this.name = 'ProviderInputRejectedError';
68
+ }
69
+ }
62
70
  export class ProviderTurnCancelledError extends Error {
63
71
  publicReplyText;
64
72
  constructor(message = 'provider turn cancelled', options) {
@@ -23,6 +23,8 @@ export declare function resolveLocalConfigAgentStateRoot(rootPath: string, agent
23
23
  export declare function resolveSharedProtocolKickoffDecisionPath(stateRootDir: string, channelId: string, anchorMessageId: string): string;
24
24
  export declare function resolveSharedProtocolStatusPath(stateRootDir: string, channelId: string, anchorMessageId: string): string;
25
25
  export declare function resolveConnectionsStatePath(stateRootDir: string): string;
26
+ export declare function resolveExecutionTelemetryOutboxPath(stateRootDir: string): string;
27
+ export declare function resolveExecutionDeliveryJournalPath(stateRootDir: string): string;
26
28
  export declare function resolveAttentionStatePath(stateRootDir: string, channelId: string): string;
27
29
  export declare function resolveCompactionStatePath(stateRootDir: string, channelId: string): string;
28
30
  export declare function resolveAuthorizationAuditPath(stateRootDir: string): string;
@@ -138,6 +138,12 @@ export function resolveSharedProtocolStatusPath(stateRootDir, channelId, anchorM
138
138
  export function resolveConnectionsStatePath(stateRootDir) {
139
139
  return join(stateRootDir, 'connections-state.sqlite');
140
140
  }
141
+ export function resolveExecutionTelemetryOutboxPath(stateRootDir) {
142
+ return join(stateRootDir, 'execution-telemetry-outbox.json');
143
+ }
144
+ export function resolveExecutionDeliveryJournalPath(stateRootDir) {
145
+ return join(stateRootDir, 'execution-delivery-journal.json');
146
+ }
141
147
  export function resolveAttentionStatePath(stateRootDir, channelId) {
142
148
  return join(stateRootDir, 'attention-state', `${encodeSegment(channelId)}.json`);
143
149
  }
package/dist/types.d.ts CHANGED
@@ -1,6 +1,15 @@
1
+ import type { AgentCapabilities, AgentStreamEvent, ProviderObservation } from './native-providers.js';
2
+ import type { ChannelFileContent as SdkChannelFileContent, ExecutionGrant } from './plugin-sdk.js';
1
3
  export type ProviderKind = 'claude' | 'codex' | 'copilot';
2
4
  export type ProjectionStrategy = 'session-brief' | 'turn-full' | 'message-only' | 'turn-thin' | 'file-brief';
3
5
  export interface ProviderCommandConfig {
6
+ providerOutputMode?: 'legacy' | 'normalized';
7
+ nativeProviderCommand?: string;
8
+ sessionWorkspaceRoot?: string;
9
+ codexConnectionMode?: 'shared' | 'stdio';
10
+ codexSharedSocketPath?: string;
11
+ /** Explicit local consent to control the shared Codex daemon under its native permissions. */
12
+ codexTrustShared?: boolean;
4
13
  claudeCommand: string;
5
14
  claudeArgs: string[];
6
15
  codexCommand: string;
@@ -99,6 +108,8 @@ export interface LocalConfigGenerateResult {
99
108
  warnings: LocalConfigGenerateWarning[];
100
109
  }
101
110
  export interface ChannelMessageEvent {
111
+ sessionTarget?: import('./plugin-sdk.js').SessionMessageTarget;
112
+ sourceCurrent?: () => boolean;
102
113
  type?: string;
103
114
  message_type?: string;
104
115
  channel_id: string;
@@ -111,6 +122,8 @@ export interface ChannelMessageEvent {
111
122
  content_type?: string;
112
123
  attachments?: HostedMessageAttachment[];
113
124
  created_at?: number;
125
+ /** Server-issued capability used only by the execution telemetry rail. */
126
+ execution_grant?: ExecutionGrant;
114
127
  [key: string]: unknown;
115
128
  }
116
129
  export interface MeResponseUser {
@@ -135,6 +148,29 @@ export interface ChannelHistoryEntry {
135
148
  createdAt: number;
136
149
  editedAt?: number;
137
150
  }
151
+ export interface ChannelFileEntry {
152
+ id: string;
153
+ ownerUserId: string;
154
+ channelId: string;
155
+ path: string;
156
+ parentPath: string;
157
+ name: string;
158
+ isDirectory: boolean;
159
+ mimeType: string;
160
+ sizeBytes: number;
161
+ source: string;
162
+ sourceMessageId: string;
163
+ createdAt: number;
164
+ updatedAt: number;
165
+ }
166
+ export type ChannelFileContent = SdkChannelFileContent;
167
+ export interface PublishChannelFileInput {
168
+ channelId: string;
169
+ path: string;
170
+ contentType: string;
171
+ base64: string;
172
+ overwrite: boolean;
173
+ }
138
174
  export interface HostedMessageAttachment {
139
175
  url: string;
140
176
  filename?: string;
@@ -289,6 +325,13 @@ export interface ProviderInput {
289
325
  incomingParts?: HostedTurnContentPart[];
290
326
  incomingEventKind?: string;
291
327
  incomingMessageType?: string;
328
+ selectedSession?: import('./plugin-sdk.js').SessionMessageTarget & {
329
+ sourceCurrent?: () => boolean;
330
+ };
331
+ independentSessionWorkspace?: {
332
+ bindingId: string;
333
+ cwd: string;
334
+ };
292
335
  collaboration?: ProviderCollaborationContext;
293
336
  collaborationOutcome?: CollaborationOutcomeSnapshot;
294
337
  attentionSnapshot?: AttentionSnapshot;
@@ -340,6 +383,7 @@ export interface LocalhostGatewayBootstrapMetadata {
340
383
  export interface TaskAssignmentThreadContext {
341
384
  active: true;
342
385
  currentTaskId?: string;
386
+ taskChannelId?: string;
343
387
  }
344
388
  export interface ChannelResolvedWorkingFolderContext {
345
389
  authority: 'channel';
@@ -416,6 +460,8 @@ export interface PreparedProviderTurnInput {
416
460
  incomingEventKind?: string;
417
461
  incomingMessageType?: string;
418
462
  prompt: string;
463
+ /** Context preparation failed; native separate-context admission must not proceed. */
464
+ contextPreparationFailed?: boolean;
419
465
  /** Claude-only session append content for ACP systemPrompt.append. */
420
466
  claudeSessionPromptAppend?: string;
421
467
  /** Shared projection-strategy selector used for provider prompt/session experiments. */
@@ -454,6 +500,12 @@ export interface ProviderReply {
454
500
  */
455
501
  sessionId?: string;
456
502
  }
503
+ export interface ProviderTokenUsage {
504
+ inputTokens: number;
505
+ outputTokens: number;
506
+ cacheReadTokens: number;
507
+ cacheWriteTokens: number;
508
+ }
457
509
  export interface PostedMessage {
458
510
  messageId: string;
459
511
  }
@@ -587,5 +639,19 @@ export type ProviderProgressUpdate = {
587
639
  run: ProviderBackgroundRunProgress;
588
640
  };
589
641
  export interface ProviderGenerateOptions {
642
+ normalizedTaskId?: string;
643
+ /** Durable Borgee input identity; distinct from a browser optimistic request id. */
644
+ normalizedInputMessageId?: string;
645
+ /** Authoritative durable Borgee body; null means unavailable. Native observations remain canonical after admission. */
646
+ normalizedInputText?: string | null;
647
+ onNormalizedObservation?: (event: AgentStreamEvent, borgeeAgentId: string, observation?: ProviderObservation, sessionCapabilities?: AgentCapabilities, sessionControlBindingId?: string, timelineEpoch?: string, sessionPublished?: boolean) => void;
648
+ normalizedStateSink?: {
649
+ observe(observation: ProviderObservation, borgeeAgentId: string, sessionCapabilities?: AgentCapabilities, sessionControlBindingId?: string, timelineEpoch?: string): void;
650
+ sessionActivity?(activity: import('./plugin-sdk.js').AgentActivity): boolean;
651
+ snapshot?(value: import('./native-providers.js').AgentSnapshot, sessionControlBindingId?: string, timelineEpoch?: string): boolean;
652
+ close(): void;
653
+ };
590
654
  onProgress?: (update: ProviderProgressUpdate) => void;
655
+ onUsage?: (usage: ProviderTokenUsage) => void;
656
+ onExecutionContinuation?: (completion: Promise<boolean>) => void;
591
657
  }
@@ -0,0 +1,14 @@
1
+ export interface TypingLease {
2
+ renew(): void;
3
+ stop(): void;
4
+ }
5
+ /**
6
+ * Keeps typing truthful without making provider completion its only release.
7
+ *
8
+ * A lease reports one pulse immediately. Visible answer updates may renew it
9
+ * at most once per interval; nothing is scheduled between updates. Browser
10
+ * expiry bounds every pulse, so a provider turn can keep running tools or
11
+ * background work while the activity rail says "working" without a hidden
12
+ * periodic heartbeat surviving indefinitely.
13
+ */
14
+ export declare function startTypingLease(reportTyping: () => void, now?: () => number): TypingLease;
@@ -0,0 +1,31 @@
1
+ const TYPING_PULSE_INTERVAL_MS = 2_000;
2
+ /**
3
+ * Keeps typing truthful without making provider completion its only release.
4
+ *
5
+ * A lease reports one pulse immediately. Visible answer updates may renew it
6
+ * at most once per interval; nothing is scheduled between updates. Browser
7
+ * expiry bounds every pulse, so a provider turn can keep running tools or
8
+ * background work while the activity rail says "working" without a hidden
9
+ * periodic heartbeat surviving indefinitely.
10
+ */
11
+ export function startTypingLease(reportTyping, now = () => performance.now()) {
12
+ let closed = false;
13
+ let lastPulseAt = now();
14
+ reportTyping();
15
+ return {
16
+ renew: () => {
17
+ if (closed) {
18
+ return;
19
+ }
20
+ const currentTime = now();
21
+ if (currentTime - lastPulseAt < TYPING_PULSE_INTERVAL_MS) {
22
+ return;
23
+ }
24
+ lastPulseAt = currentTime;
25
+ reportTyping();
26
+ },
27
+ stop: () => {
28
+ closed = true;
29
+ },
30
+ };
31
+ }
@@ -0,0 +1,211 @@
1
+ Copyright (c) 2025-present Mohamed Boudra
2
+
3
+ Portions of this software are licensed as follows:
4
+
5
+ * Third-party components incorporated into Paseo remain licensed under
6
+ the licenses provided by their respective copyright holders.
7
+ * Except for those third-party components, Paseo is licensed under the
8
+ Apache License, Version 2.0, reproduced below.
9
+
10
+
11
+ Apache License
12
+ Version 2.0, January 2004
13
+ http://www.apache.org/licenses/
14
+
15
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
16
+
17
+ 1. Definitions.
18
+
19
+ "License" shall mean the terms and conditions for use, reproduction,
20
+ and distribution as defined by Sections 1 through 9 of this document.
21
+
22
+ "Licensor" shall mean the copyright owner or entity authorized by
23
+ the copyright owner that is granting the License.
24
+
25
+ "Legal Entity" shall mean the union of the acting entity and all
26
+ other entities that control, are controlled by, or are under common
27
+ control with that entity. For the purposes of this definition,
28
+ "control" means (i) the power, direct or indirect, to cause the
29
+ direction or management of such entity, whether by contract or
30
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
31
+ outstanding shares, or (iii) beneficial ownership of such entity.
32
+
33
+ "You" (or "Your") shall mean an individual or Legal Entity
34
+ exercising permissions granted by this License.
35
+
36
+ "Source" form shall mean the preferred form for making modifications,
37
+ including but not limited to software source code, documentation
38
+ source, and configuration files.
39
+
40
+ "Object" form shall mean any form resulting from mechanical
41
+ transformation or translation of a Source form, including but
42
+ not limited to compiled object code, generated documentation,
43
+ and conversions to other media types.
44
+
45
+ "Work" shall mean the work of authorship, whether in Source or
46
+ Object form, made available under the License, as indicated by a
47
+ copyright notice that is included in or attached to the work
48
+ (an example is provided in the Appendix below).
49
+
50
+ "Derivative Works" shall mean any work, whether in Source or Object
51
+ form, that is based on (or derived from) the Work and for which the
52
+ editorial revisions, annotations, elaborations, or other modifications
53
+ represent, as a whole, an original work of authorship. For the purposes
54
+ of this License, Derivative Works shall not include works that remain
55
+ separable from, or merely link (or bind by name) to the interfaces of,
56
+ the Work and Derivative Works thereof.
57
+
58
+ "Contribution" shall mean any work of authorship, including
59
+ the original version of the Work and any modifications or additions
60
+ to that Work or Derivative Works thereof, that is intentionally
61
+ submitted to Licensor for inclusion in the Work by the copyright owner
62
+ or by an individual or Legal Entity authorized to submit on behalf of
63
+ the copyright owner. For the purposes of this definition, "submitted"
64
+ means any form of electronic, verbal, or written communication sent
65
+ to the Licensor or its representatives, including but not limited to
66
+ communication on electronic mailing lists, source code control systems,
67
+ and issue tracking systems that are managed by, or on behalf of, the
68
+ Licensor for the purpose of discussing and improving the Work, but
69
+ excluding communication that is conspicuously marked or otherwise
70
+ designated in writing by the copyright owner as "Not a Contribution."
71
+
72
+ "Contributor" shall mean Licensor and any individual or Legal Entity
73
+ on behalf of whom a Contribution has been received by Licensor and
74
+ subsequently incorporated within the Work.
75
+
76
+ 2. Grant of Copyright License. Subject to the terms and conditions of
77
+ this License, each Contributor hereby grants to You a perpetual,
78
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
79
+ copyright license to reproduce, prepare Derivative Works of,
80
+ publicly display, publicly perform, sublicense, and distribute the
81
+ Work and such Derivative Works in Source or Object form.
82
+
83
+ 3. Grant of Patent License. Subject to the terms and conditions of
84
+ this License, each Contributor hereby grants to You a perpetual,
85
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
86
+ (except as stated in this section) patent license to make, have made,
87
+ use, offer to sell, sell, import, and otherwise transfer the Work,
88
+ where such license applies only to those patent claims licensable
89
+ by such Contributor that are necessarily infringed by their
90
+ Contribution(s) alone or by combination of their Contribution(s)
91
+ with the Work to which such Contribution(s) was submitted. If You
92
+ institute patent litigation against any entity (including a
93
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
94
+ or a Contribution incorporated within the Work constitutes direct
95
+ or contributory patent infringement, then any patent licenses
96
+ granted to You under this License for that Work shall terminate
97
+ as of the date such litigation is filed.
98
+
99
+ 4. Redistribution. You may reproduce and distribute copies of the
100
+ Work or Derivative Works thereof in any medium, with or without
101
+ modifications, and in Source or Object form, provided that You
102
+ meet the following conditions:
103
+
104
+ (a) You must give any other recipients of the Work or
105
+ Derivative Works a copy of this License; and
106
+
107
+ (b) You must cause any modified files to carry prominent notices
108
+ stating that You changed the files; and
109
+
110
+ (c) You must retain, in the Source form of any Derivative Works
111
+ that You distribute, all copyright, patent, trademark, and
112
+ attribution notices from the Source form of the Work,
113
+ excluding those notices that do not pertain to any part of
114
+ the Derivative Works; and
115
+
116
+ (d) If the Work includes a "NOTICE" text file as part of its
117
+ distribution, then any Derivative Works that You distribute must
118
+ include a readable copy of the attribution notices contained
119
+ within such NOTICE file, excluding those notices that do not
120
+ pertain to any part of the Derivative Works, in at least one
121
+ of the following places: within a NOTICE text file distributed
122
+ as part of the Derivative Works; within the Source form or
123
+ documentation, if provided along with the Derivative Works; or,
124
+ within a display generated by the Derivative Works, if and
125
+ wherever such third-party notices normally appear. The contents
126
+ of the NOTICE file are for informational purposes only and
127
+ do not modify the License. You may add Your own attribution
128
+ notices within Derivative Works that You distribute, alongside
129
+ or as an addendum to the NOTICE text from the Work, provided
130
+ that such additional attribution notices cannot be construed
131
+ as modifying the License.
132
+
133
+ You may add Your own copyright statement to Your modifications and
134
+ may provide additional or different license terms and conditions
135
+ for use, reproduction, or distribution of Your modifications, or
136
+ for any such Derivative Works as a whole, provided Your use,
137
+ reproduction, and distribution of the Work otherwise complies with
138
+ the conditions stated in this License.
139
+
140
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
141
+ any Contribution intentionally submitted for inclusion in the Work
142
+ by You to the Licensor shall be under the terms and conditions of
143
+ this License, without any additional terms or conditions.
144
+ Notwithstanding the above, nothing herein shall supersede or modify
145
+ the terms of any separate license agreement you may have executed
146
+ with Licensor regarding such Contributions.
147
+
148
+ 6. Trademarks. This License does not grant permission to use the trade
149
+ names, trademarks, service marks, or product names of the Licensor,
150
+ except as required for reasonable and customary use in describing the
151
+ origin of the Work and reproducing the content of the NOTICE file.
152
+
153
+ 7. Disclaimer of Warranty. Unless required by applicable law or
154
+ agreed to in writing, Licensor provides the Work (and each
155
+ Contributor provides its Contributions) on an "AS IS" BASIS,
156
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
157
+ implied, including, without limitation, any warranties or conditions
158
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
159
+ PARTICULAR PURPOSE. You are solely responsible for determining the
160
+ appropriateness of using or redistributing the Work and assume any
161
+ risks associated with Your exercise of permissions under this License.
162
+
163
+ 8. Limitation of Liability. In no event and under no legal theory,
164
+ whether in tort (including negligence), contract, or otherwise,
165
+ unless required by applicable law (such as deliberate and grossly
166
+ negligent acts) or agreed to in writing, shall any Contributor be
167
+ liable to You for damages, including any direct, indirect, special,
168
+ incidental, or consequential damages of any character arising as a
169
+ result of this License or out of the use or inability to use the
170
+ Work (including but not limited to damages for loss of goodwill,
171
+ work stoppage, computer failure or malfunction, or any and all
172
+ other commercial damages or losses), even if such Contributor
173
+ has been advised of the possibility of such damages.
174
+
175
+ 9. Accepting Warranty or Additional Liability. While redistributing
176
+ the Work or Derivative Works thereof, You may choose to offer,
177
+ and charge a fee for, acceptance of support, warranty, indemnity,
178
+ or other liability obligations and/or rights consistent with this
179
+ License. However, in accepting such obligations, You may act only
180
+ on Your own behalf and on Your sole responsibility, not on behalf
181
+ of any other Contributor, and only if You agree to indemnify,
182
+ defend, and hold each Contributor harmless for any liability
183
+ incurred by, or claims asserted against, such Contributor by reason
184
+ of your accepting any such warranty or additional liability.
185
+
186
+ END OF TERMS AND CONDITIONS
187
+
188
+ APPENDIX: How to apply the Apache License to your work.
189
+
190
+ To apply the Apache License to your work, attach the following
191
+ boilerplate notice, with the fields enclosed by brackets "[]"
192
+ replaced with your own identifying information. (Don't include
193
+ the brackets!) The text should be enclosed in the appropriate
194
+ comment syntax for the file format. We also recommend that a
195
+ file or class name and description of purpose be included on the
196
+ same "printed page" as the copyright notice for easier
197
+ identification within third-party archives.
198
+
199
+ Copyright [yyyy] [name of copyright owner]
200
+
201
+ Licensed under the Apache License, Version 2.0 (the "License");
202
+ you may not use this file except in compliance with the License.
203
+ You may obtain a copy of the License at
204
+
205
+ http://www.apache.org/licenses/LICENSE-2.0
206
+
207
+ Unless required by applicable law or agreed to in writing, software
208
+ distributed under the License is distributed on an "AS IS" BASIS,
209
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
210
+ See the License for the specific language governing permissions and
211
+ limitations under the License.
@@ -0,0 +1,13 @@
1
+ This package contains code derived from Paseo commit
2
+ 463415ae846cbcfef0df691e413a1a73a9213757.
3
+
4
+ Paseo copyright (c) 2025-present Mohamed Boudra.
5
+ Paseo is licensed under the Apache License, Version 2.0, reproduced in LICENSE.
6
+
7
+ The derived code has been adapted to Borgee-owned Provider contracts and
8
+ substantially reorganized into transport, native parsing, projection, history,
9
+ session, and provider modules.
10
+
11
+ Native daemon client recovery and routing are derived from Agent Remote Control
12
+ commit 7174e085e60cd5bba80653c993870261fe040936, packages/codex-daemon-client
13
+ and its Provider runtime bridge, licensed under Apache-2.0.