@borgee/agents-host 0.2.101 → 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.
- package/README.md +77 -5
- package/dist/agents-host.d.ts +8 -0
- package/dist/agents-host.js +355 -23
- package/dist/catalog-worker.js +21 -0
- package/dist/catalog-worker.js.map +7 -0
- package/dist/chat/chat-control-plane.d.ts +7 -2
- package/dist/chat/normalized-input.d.ts +9 -0
- package/dist/chat/normalized-input.js +24 -0
- package/dist/chat/sdk-chat-control-plane.d.ts +18 -3
- package/dist/chat/sdk-chat-control-plane.js +44 -9
- package/dist/cli-args.d.ts +1 -1
- package/dist/cli-args.js +13 -4
- package/dist/config.d.ts +3 -1
- package/dist/config.js +25 -0
- package/dist/context/injection.d.ts +16 -0
- package/dist/context/injection.js +37 -21
- package/dist/context/prompt.d.ts +12 -0
- package/dist/context/prompt.js +25 -0
- package/dist/context/turn-preparation.d.ts +2 -1
- package/dist/context/turn-preparation.js +15 -0
- package/dist/gateway/localhost-gateway.js +33 -8
- package/dist/hosted-turn-content.js +3 -2
- package/dist/local-config.js +34 -1
- package/dist/managed-daemon.js +15 -0
- package/dist/native-environment.d.ts +2 -0
- package/dist/native-environment.js +9 -0
- package/dist/native-protocol-types/codec.d.ts +49 -0
- package/dist/native-protocol-types/commands.d.ts +71 -0
- package/dist/native-protocol-types/compatibility.d.ts +5 -0
- package/dist/native-protocol-types/cursor.d.ts +7 -0
- package/dist/native-protocol-types/envelope.d.ts +1105 -0
- package/dist/native-protocol-types/file-changes.d.ts +20 -0
- package/dist/native-protocol-types/history.d.ts +487 -0
- package/dist/native-protocol-types/index.d.ts +18 -0
- package/dist/native-protocol-types/interactions.d.ts +619 -0
- package/dist/native-protocol-types/messages.d.ts +2482 -0
- package/dist/native-protocol-types/public-validation.d.ts +10 -0
- package/dist/native-protocol-types/remote-host-uplink.d.ts +67 -0
- package/dist/native-protocol-types/resources.d.ts +126 -0
- package/dist/native-protocol-types/session-settings.d.ts +22 -0
- package/dist/native-protocol-types/snapshot.d.ts +575 -0
- package/dist/native-protocol-types/timeline.d.ts +1503 -0
- package/dist/native-protocol-types/tool-result.d.ts +26 -0
- package/dist/native-protocol-types/uplink.d.ts +56 -0
- package/dist/native-protocol-types/version.d.ts +5 -0
- package/dist/native-provider-types/commands.d.ts +51 -0
- package/dist/native-provider-types/control.d.ts +192 -0
- package/dist/native-provider-types/file-changes.d.ts +9 -0
- package/dist/native-provider-types/index.d.ts +8 -0
- package/dist/native-provider-types/interactions.d.ts +7 -0
- package/dist/native-provider-types/observation.d.ts +209 -0
- package/dist/native-provider-types/provider.d.ts +124 -0
- package/dist/native-provider-types/session-settings.d.ts +17 -0
- package/dist/native-provider-types/testing.d.ts +27 -0
- package/dist/native-provider-types/tool-result.d.ts +21 -0
- package/dist/native-providers.d.ts +21 -0
- package/dist/native-providers.js +18402 -0
- package/dist/native-providers.js.map +7 -0
- package/dist/plugin-sdk.js +10640 -225
- package/dist/plugin-sdk.js.map +4 -4
- package/dist/policy/copilot-permission.js +1 -8
- package/dist/providers/copilot/sdk-session.js +8 -1
- package/dist/providers/create-provider.js +20 -0
- package/dist/providers/normalized/adapter.d.ts +107 -0
- package/dist/providers/normalized/adapter.js +1650 -0
- package/dist/providers/normalized/control-policy.d.ts +5 -0
- package/dist/providers/normalized/control-policy.js +12 -0
- package/dist/providers/normalized/interactions.d.ts +3 -0
- package/dist/providers/normalized/interactions.js +39 -0
- package/dist/providers/normalized/legacy-input-ownership.d.ts +34 -0
- package/dist/providers/normalized/legacy-input-ownership.js +123 -0
- package/dist/providers/normalized/session-management.d.ts +67 -0
- package/dist/providers/normalized/session-management.js +334 -0
- package/dist/providers/normalized/session-ownership.d.ts +3 -0
- package/dist/providers/normalized/session-ownership.js +90 -0
- package/dist/providers/provider-adapter.d.ts +43 -1
- package/dist/providers/provider-adapter.js +8 -0
- package/dist/types.d.ts +34 -9
- package/dist/vendor/agent-provider-codex/LICENSE +211 -0
- package/dist/vendor/agent-provider-codex/NOTICE +13 -0
- package/package.json +22 -13
- package/skills/borgee-agent/SKILL.md +1 -1
- package/skills/borgee-agent/scripts/borgee-agent.mjs +24 -3
- package/skills/borgee-agent/scripts/borgee-agent.py +28 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { summarizeError } from '../debug.js';
|
|
2
2
|
const LEGACY_MISSING_ALLOW_OPTION_MESSAGE = 'Copilot ACP requested permission but did not offer an allow option';
|
|
3
|
-
const SDK_APPROVE_FOR_SESSION_OPTION_ID = 'sdk-approve-for-session';
|
|
4
3
|
const SDK_APPROVE_ONCE_OPTION_ID = 'sdk-approve-once';
|
|
5
4
|
const SDK_REJECT_OPTION_ID = 'sdk-reject';
|
|
6
5
|
function legacySelectPermissionOption(options) {
|
|
@@ -279,12 +278,8 @@ export function resolveCopilotSdkPermissionResponse(context) {
|
|
|
279
278
|
feedback: 'Managed policy requires interactive approval, which this hosted runtime cannot provide.',
|
|
280
279
|
};
|
|
281
280
|
}
|
|
281
|
+
// Session grants bypass subsequent host policy checks; approve each SDK request independently.
|
|
282
282
|
const options = [
|
|
283
|
-
{
|
|
284
|
-
optionId: SDK_APPROVE_FOR_SESSION_OPTION_ID,
|
|
285
|
-
name: 'Allow for this session',
|
|
286
|
-
kind: 'allow_always',
|
|
287
|
-
},
|
|
288
283
|
{
|
|
289
284
|
optionId: SDK_APPROVE_ONCE_OPTION_ID,
|
|
290
285
|
name: 'Allow once',
|
|
@@ -312,8 +307,6 @@ export function resolveCopilotSdkPermissionResponse(context) {
|
|
|
312
307
|
return { kind: 'reject' };
|
|
313
308
|
}
|
|
314
309
|
switch (response.outcome.optionId) {
|
|
315
|
-
case SDK_APPROVE_FOR_SESSION_OPTION_ID:
|
|
316
|
-
return { kind: 'approve-for-session' };
|
|
317
310
|
case SDK_APPROVE_ONCE_OPTION_ID:
|
|
318
311
|
return { kind: 'approve-once' };
|
|
319
312
|
default:
|
|
@@ -836,7 +836,7 @@ export class CopilotSdkSessionAdapter {
|
|
|
836
836
|
this.discardAutonomousTurn(turn);
|
|
837
837
|
return;
|
|
838
838
|
}
|
|
839
|
-
if (event.type === 'assistant.idle') {
|
|
839
|
+
if (event.type === 'assistant.idle' || event.type === 'session.idle') {
|
|
840
840
|
this.finishAutonomousTurn(turn);
|
|
841
841
|
}
|
|
842
842
|
}
|
|
@@ -992,6 +992,10 @@ export class CopilotSdkSessionAdapter {
|
|
|
992
992
|
turn.reject(new Error(event.data.message));
|
|
993
993
|
return;
|
|
994
994
|
}
|
|
995
|
+
case 'session.idle': {
|
|
996
|
+
this.finishActiveTurn(false);
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
995
999
|
case 'assistant.idle': {
|
|
996
1000
|
this.finishActiveTurn(event.data.aborted === true);
|
|
997
1001
|
return;
|
|
@@ -1172,6 +1176,9 @@ export class CopilotSdkSessionAdapter {
|
|
|
1172
1176
|
case 'tool.execution_start':
|
|
1173
1177
|
case 'tool.execution_complete':
|
|
1174
1178
|
return event.data.turnId ?? this.currentRootTurnId;
|
|
1179
|
+
case 'session.idle':
|
|
1180
|
+
// Session idle is terminal only after the owned root turn has ended.
|
|
1181
|
+
return this.currentRootTurnId ? undefined : this.lastRootTurnId;
|
|
1175
1182
|
case 'assistant.usage':
|
|
1176
1183
|
case 'assistant.idle':
|
|
1177
1184
|
return this.currentRootTurnId ?? this.lastRootTurnId;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { configureHostedNativeSession, createHostedNativeProvider } from '../native-providers.js';
|
|
3
|
+
import { createSessionOwnershipLock, readProtectedCodexSessions } from './normalized/session-ownership.js';
|
|
4
|
+
import { NormalizedProviderAdapter } from './normalized/adapter.js';
|
|
1
5
|
import { FileChannelContextStore } from '../context/injection.js';
|
|
2
6
|
import { ServerProjectionStrategyResolver } from '../context/projection-strategy.js';
|
|
3
7
|
import { createProviderConnectionsSessionStore } from '../connections-state-store.js';
|
|
@@ -199,6 +203,22 @@ export function createProvider(config, debugLogger, options = {}) {
|
|
|
199
203
|
return projectionStrategyResolver.resolve(input.channelId);
|
|
200
204
|
},
|
|
201
205
|
});
|
|
206
|
+
const outputMode = config.providerOutputMode ?? 'legacy';
|
|
207
|
+
if (outputMode === 'normalized') {
|
|
208
|
+
const provider = createHostedNativeProvider(config.provider, config.nativeProviderCommand, config);
|
|
209
|
+
return new NormalizedProviderAdapter({
|
|
210
|
+
...(config.provider === 'codex' ? { sessionManagement: { root: config.sessionWorkspaceRoot,
|
|
211
|
+
store: new FileCodexChannelSessionStore({ resolvePath: () => join(config.stateRootDir, 'independent-sessions', 'codex.json') }),
|
|
212
|
+
loadProtectedNativeIds: () => readProtectedCodexSessions(config.stateRootDir),
|
|
213
|
+
withOwnershipLock: createSessionOwnershipLock(join(config.stateRootDir, 'independent-sessions')),
|
|
214
|
+
} } : {}),
|
|
215
|
+
provider, prepare: (input) => turnPreparer.prepare(input),
|
|
216
|
+
...(config.provider === 'codex' ? { prepareSession: (channelId) => turnPreparer.prepareSession(channelId, 'codex') } : {}),
|
|
217
|
+
resolveAgentId: () => config.resolveStableAgentId?.(), serverUrl: config.borgeeBaseUrl,
|
|
218
|
+
configureSession: (session) => configureHostedNativeSession(session, config.provider),
|
|
219
|
+
store: new FileCodexChannelSessionStore({ resolvePath: (agentId) => join(config.stateRootDir, 'native-sessions', config.provider, encodeURIComponent(agentId) + '.json') }),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
202
222
|
switch (config.provider) {
|
|
203
223
|
case 'claude': {
|
|
204
224
|
return createClaudeProvider(config, debugLogger, connectionsStateGateEnabled, turnPreparer, idleBackendShutdownMs);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type SessionDirectoryRequest, type SessionDirectoryResult, type SessionObservationRequest, type SessionObservationResult, type ServerRequestContext } from '../../plugin-sdk.js';
|
|
2
|
+
import { type SessionControlRequest } from '../../plugin-sdk.js';
|
|
3
|
+
import type { AgentInteractionResponse, AgentProviderAdapter, AgentSession } from '../../native-providers.js';
|
|
4
|
+
import type { PreparedPromptContext, PreparedProviderTurnInput, ProviderGenerateOptions, ProviderInput, ProviderReply } from '../../types.js';
|
|
5
|
+
import { type ProviderAdapter, type ProviderSessionControlContext, type ProviderSessionControlResult } from '../provider-adapter.js';
|
|
6
|
+
import { type HostSessionManagementOptions } from './session-management.js';
|
|
7
|
+
interface SessionStore {
|
|
8
|
+
load(agentId: string): Promise<Record<string, string>>;
|
|
9
|
+
save(agentId: string, sessions: Record<string, string>): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export interface NormalizedProviderOptions {
|
|
12
|
+
provider: AgentProviderAdapter;
|
|
13
|
+
prepare(input: ProviderInput): Promise<PreparedProviderTurnInput>;
|
|
14
|
+
prepareSession?(channelId: string): Promise<PreparedPromptContext | undefined>;
|
|
15
|
+
resolveAgentId(): string | undefined;
|
|
16
|
+
serverUrl: string;
|
|
17
|
+
store: SessionStore;
|
|
18
|
+
configureSession(session: AgentSession): Promise<void>;
|
|
19
|
+
sessionManagement?: Omit<HostSessionManagementOptions, 'provider' | 'find' | 'register' | 'resolveAgentId' | 'serverUrl'>;
|
|
20
|
+
}
|
|
21
|
+
/** Owns Host binding and business replies; native event interpretation stays in providers. */
|
|
22
|
+
export declare class NormalizedProviderAdapter implements ProviderAdapter {
|
|
23
|
+
private readonly options;
|
|
24
|
+
readonly outputMode: "normalized";
|
|
25
|
+
readonly capabilities: import("../provider-adapter.js").ProviderCapabilities;
|
|
26
|
+
private readonly bindings;
|
|
27
|
+
private readonly bindingRecords;
|
|
28
|
+
private readonly relationPasses;
|
|
29
|
+
private readonly deferredRelations;
|
|
30
|
+
private readonly busy;
|
|
31
|
+
private readonly stores;
|
|
32
|
+
private saving;
|
|
33
|
+
private defaultAdmission;
|
|
34
|
+
private disposed;
|
|
35
|
+
private readonly management?;
|
|
36
|
+
constructor(options: NormalizedProviderOptions);
|
|
37
|
+
private hasIndependentOwner;
|
|
38
|
+
private get supportsDefaultOpening();
|
|
39
|
+
get supportsSessionManagement(): boolean;
|
|
40
|
+
describeSessionManagement(): Promise<import('../../plugin-sdk.js').SessionManagementAvailability>;
|
|
41
|
+
manageSession(request: import('../../plugin-sdk.js').SessionManagementRequest, context: ServerRequestContext): Promise<unknown>;
|
|
42
|
+
private openDefaultSession;
|
|
43
|
+
private registerIndependentSession;
|
|
44
|
+
get sessionInputOperations(): readonly ('start_turn' | 'steer' | 'next_turn')[];
|
|
45
|
+
get supportsSessionInput(): boolean;
|
|
46
|
+
private sessionPublication?;
|
|
47
|
+
setSessionPublication(publication: Parameters<NonNullable<ProviderAdapter['setSessionPublication']>>[0]): void;
|
|
48
|
+
publishSessionBindings(): void;
|
|
49
|
+
private publishAvailability;
|
|
50
|
+
private setAvailability;
|
|
51
|
+
private visibleRuntime;
|
|
52
|
+
private publishBinding;
|
|
53
|
+
private publishActivity;
|
|
54
|
+
private publisher;
|
|
55
|
+
private publishPreTurnError;
|
|
56
|
+
private publishTimeline;
|
|
57
|
+
listSessions(request: SessionDirectoryRequest, context: ServerRequestContext): SessionDirectoryResult;
|
|
58
|
+
describeSession(request: import('../../plugin-sdk.js').SessionDescriptionRequest, context: ServerRequestContext): import('../../plugin-sdk.js').SessionControlTarget | undefined;
|
|
59
|
+
observeSession(request: SessionObservationRequest, context: ServerRequestContext): Promise<SessionObservationResult>;
|
|
60
|
+
generateReply(input: ProviderInput, options?: ProviderGenerateOptions): Promise<ProviderReply>;
|
|
61
|
+
private bindingCurrent;
|
|
62
|
+
private controlBinding;
|
|
63
|
+
controlSession(request: SessionControlRequest, context: ProviderSessionControlContext): Promise<ProviderSessionControlResult>;
|
|
64
|
+
private registerInput;
|
|
65
|
+
private confirmInput;
|
|
66
|
+
private releaseExecution;
|
|
67
|
+
private reconcileAssociationMetadata;
|
|
68
|
+
private applyAssociation;
|
|
69
|
+
private observeOwned;
|
|
70
|
+
private processOwnedObservation;
|
|
71
|
+
private sendInput;
|
|
72
|
+
private finishLocalCommand;
|
|
73
|
+
private persistConfirmedBinding;
|
|
74
|
+
private withDefaultAdmission;
|
|
75
|
+
private bindingFor;
|
|
76
|
+
private bindingForDefault;
|
|
77
|
+
private admitChildren;
|
|
78
|
+
private adoptKnownChildren;
|
|
79
|
+
private observeSessionState;
|
|
80
|
+
private selectBinding;
|
|
81
|
+
private observe;
|
|
82
|
+
private queueObservation;
|
|
83
|
+
private drainObservations;
|
|
84
|
+
private processObservation;
|
|
85
|
+
private bindingCapabilities;
|
|
86
|
+
private retireInteractions;
|
|
87
|
+
private observeNativeTurn;
|
|
88
|
+
private restoreSession;
|
|
89
|
+
private observeEvent;
|
|
90
|
+
respondInteraction(input: {
|
|
91
|
+
channelId: string;
|
|
92
|
+
taskId?: string;
|
|
93
|
+
agentId: string;
|
|
94
|
+
requestId: string;
|
|
95
|
+
response: AgentInteractionResponse;
|
|
96
|
+
binding?: Pick<SessionControlRequest, 'binding_id' | 'native_session_id' | 'connection_generation'>;
|
|
97
|
+
}, context?: import('../../plugin-sdk.js').ServerRequestContext): Promise<AgentInteractionResponse>;
|
|
98
|
+
/** Capture and publication share the observation loop's synchronous ordering. */
|
|
99
|
+
syncNormalizedActivity(channelId: string, bindingId?: string): boolean;
|
|
100
|
+
cancelTurn(channelId: string, target?: Pick<SessionControlRequest, 'binding_id' | 'native_session_id' | 'connection_generation'>, context?: import('../../plugin-sdk.js').ServerRequestContext): Promise<boolean>;
|
|
101
|
+
interruptTurn(channelId: string): Promise<boolean>;
|
|
102
|
+
cancelSession(channelId: string): Promise<boolean>;
|
|
103
|
+
private closeBinding;
|
|
104
|
+
private disposeBinding;
|
|
105
|
+
dispose(): Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
export {};
|