@sema-agent/client-core 0.101.0 → 0.102.0
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/CHANGELOG.md +57 -0
- package/README.md +12 -7
- package/dist/adapt/toolCards.d.ts +2 -1
- package/dist/adapt/toolCards.js +20 -6
- package/dist/adapt.d.ts +1 -1
- package/dist/adapt.js +1 -1
- package/dist/adapter/downstream/eventToSdkMessage.js +6 -68
- package/dist/adapter/downstream/wiringManifestView.d.ts +1 -0
- package/dist/adapter/downstream/wiringManifestView.js +138 -0
- package/dist/compensations.js +1 -1
- package/dist/displayUntrusted.d.ts +8 -4
- package/dist/displayUntrusted.js +769 -96
- package/dist/engineRowRef.js +1 -0
- package/dist/fleet/fleetProjection.js +1 -1
- package/dist/i18n/messages.en.d.ts +38 -0
- package/dist/i18n/messages.en.js +38 -0
- package/dist/i18n/messages.zh.js +40 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/interactiveHalt.d.ts +3 -1
- package/dist/interactiveHalt.js +2 -0
- package/dist/interactiveInterrupt.d.ts +2 -0
- package/dist/interactiveInterrupt.js +15 -0
- package/dist/modsFace.d.ts +8 -0
- package/dist/modsFace.js +59 -0
- package/dist/ownKey.d.ts +1 -0
- package/dist/ownKey.js +15 -0
- package/dist/printToolResultFrame.js +1 -1
- package/dist/request/printNotification.js +1 -1
- package/dist/request/taskRequest.d.ts +21 -0
- package/dist/request/taskRequest.js +123 -7
- package/dist/seam.js +1 -1
- package/dist/seatContract.d.ts +22 -6
- package/dist/seatContract.js +35 -6
- package/dist/sessionBackground.d.ts +165 -0
- package/dist/sessionBackground.js +781 -0
- package/dist/sessionBackgroundHandoff.d.ts +54 -0
- package/dist/sessionBackgroundHandoff.js +321 -0
- package/dist/sessionMap.js +4 -1
- package/dist/settingsCredentialKeyPaths.js +2 -17
- package/dist/thinkingLatch.d.ts +69 -0
- package/dist/thinkingLatch.js +255 -0
- package/dist/thinkingLatchWords.d.ts +7 -0
- package/dist/thinkingLatchWords.js +4 -0
- package/dist/toolResult.js +2 -24
- package/docs/INTEGRATION-CLIENTS.md +309 -10
- package/package.json +1 -1
- package/dist/argvFlagValue.d.ts +0 -8
- package/dist/argvFlagValue.js +0 -37
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { AgentClient, AgentEvent, TaskRequest } from '@sema-agent/sdk';
|
|
2
|
+
import { type EnvLike } from './hostEnv.js';
|
|
3
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
4
|
+
export type SessionBackgroundableReading = {
|
|
5
|
+
readonly kind: 'advertised';
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'declined';
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'not_reported';
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'unreadable';
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'unobserved';
|
|
14
|
+
};
|
|
15
|
+
export declare function projectSessionBackgroundable(caps: {} | null | undefined): SessionBackgroundableReading | undefined;
|
|
16
|
+
export declare function readSessionBackgroundable(baseUrl?: string | undefined): SessionBackgroundableReading;
|
|
17
|
+
export type InteractiveEngineLane = 'self-spawned' | 'external';
|
|
18
|
+
export interface InteractiveEngineWireInit {
|
|
19
|
+
readonly baseUrl: string;
|
|
20
|
+
readonly lane: InteractiveEngineLane;
|
|
21
|
+
readonly tasks: Pick<AgentClient['tasks'], 'stream'>;
|
|
22
|
+
readonly runs: Pick<AgentClient['runs'], 'events' | 'get'>;
|
|
23
|
+
}
|
|
24
|
+
export interface InteractiveEngineWire {
|
|
25
|
+
readonly baseUrl: string;
|
|
26
|
+
readonly lane: InteractiveEngineLane;
|
|
27
|
+
}
|
|
28
|
+
type SdkStreamOptions = Parameters<AgentClient['tasks']['stream']>[1];
|
|
29
|
+
type SdkEventsOptions = NonNullable<Parameters<AgentClient['runs']['events']>[1]>;
|
|
30
|
+
type SdkGetOptions = NonNullable<Parameters<AgentClient['runs']['get']>[1]>;
|
|
31
|
+
type SdkRunRecord = Awaited<ReturnType<AgentClient['runs']['get']>>;
|
|
32
|
+
export type OpeningPhase = 'opening' | 'bound' | 'running' | 'ended-unstarted' | 'finished' | 'stream-ended' | 'handing-off' | 'handed-off' | 'engine-ended';
|
|
33
|
+
export interface OpeningRecordView {
|
|
34
|
+
readonly phase: OpeningPhase;
|
|
35
|
+
readonly inconsistent: boolean;
|
|
36
|
+
readonly capsGenAtBind: number | undefined;
|
|
37
|
+
readonly stopRequested: boolean;
|
|
38
|
+
readonly stamped: boolean;
|
|
39
|
+
readonly postureReason: InteractiveDetachPostureReason;
|
|
40
|
+
readonly proof: 'loopback-self-spawned' | 'none';
|
|
41
|
+
readonly taskId: string | undefined;
|
|
42
|
+
readonly sessionId: string | undefined;
|
|
43
|
+
readonly openAsks: ReadonlyMap<string, number | undefined>;
|
|
44
|
+
readonly askUnacked: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface OpeningRecord extends OpeningRecordView {
|
|
47
|
+
readonly openingId: number;
|
|
48
|
+
readonly sessionKey: string | undefined;
|
|
49
|
+
phase: OpeningPhase;
|
|
50
|
+
inconsistent: boolean;
|
|
51
|
+
capsGenAtBind: number | undefined;
|
|
52
|
+
stopRequested: boolean;
|
|
53
|
+
stamped: boolean;
|
|
54
|
+
postureReason: InteractiveDetachPostureReason;
|
|
55
|
+
proof: 'loopback-self-spawned' | 'none';
|
|
56
|
+
taskId: string | undefined;
|
|
57
|
+
sessionId: string | undefined;
|
|
58
|
+
readonly openAsks: Map<string, number | undefined>;
|
|
59
|
+
askUnacked: boolean;
|
|
60
|
+
replay: boolean;
|
|
61
|
+
readonly tear: (reason: string) => void;
|
|
62
|
+
}
|
|
63
|
+
export interface HandedOffEntry {
|
|
64
|
+
readonly taskId: string;
|
|
65
|
+
readonly sessionKey: string;
|
|
66
|
+
state: 'running' | 'ended' | 'unconfirmed';
|
|
67
|
+
readonly stop: (cause: 'disposed' | 'engine-ended') => void;
|
|
68
|
+
readonly reconcile: () => void;
|
|
69
|
+
}
|
|
70
|
+
export interface WireState {
|
|
71
|
+
retired: boolean;
|
|
72
|
+
readonly baseUrl: string;
|
|
73
|
+
readonly lane: InteractiveEngineLane;
|
|
74
|
+
readonly stream: (req: TaskRequest, opts: SdkStreamOptions) => AsyncGenerator<AgentEvent>;
|
|
75
|
+
readonly events: (taskId: string, opts: SdkEventsOptions) => AsyncGenerator<AgentEvent>;
|
|
76
|
+
readonly get: (taskId: string, opts: SdkGetOptions) => Promise<SdkRunRecord>;
|
|
77
|
+
readonly bySession: Map<string, OpeningRecord>;
|
|
78
|
+
readonly byTask: Map<string, OpeningRecord>;
|
|
79
|
+
readonly order: OpeningRecord[];
|
|
80
|
+
readonly handedOff: Map<string, HandedOffEntry>;
|
|
81
|
+
nextOpeningId: number;
|
|
82
|
+
}
|
|
83
|
+
export declare const OPENING_RECORD_CAP = 256;
|
|
84
|
+
export type OwnSlot = {
|
|
85
|
+
readonly state: 'absent';
|
|
86
|
+
} | {
|
|
87
|
+
readonly state: 'unreadable';
|
|
88
|
+
} | {
|
|
89
|
+
readonly state: 'data';
|
|
90
|
+
readonly value: {} | null;
|
|
91
|
+
};
|
|
92
|
+
export declare function ownSlotOf(o: object, key: string): OwnSlot;
|
|
93
|
+
export declare function wireStateOf(wire: InteractiveEngineWire | null | undefined): WireState | undefined;
|
|
94
|
+
export declare function interactiveEngineWire(init: InteractiveEngineWireInit): InteractiveEngineWire | undefined;
|
|
95
|
+
export declare function retireInteractiveEngineWire(wire: InteractiveEngineWire): void;
|
|
96
|
+
export interface InteractiveOpeningInput {
|
|
97
|
+
readonly sessionKey: string;
|
|
98
|
+
readonly reattachable: boolean;
|
|
99
|
+
readonly env?: EnvLike;
|
|
100
|
+
}
|
|
101
|
+
export type InteractiveDetachPostureReason = 'self-spawned' | 'unreadable-input' | 'retired-wire' | 'env-off' | 'not-reattachable' | 'declined' | 'unacknowledged' | 'not_reported' | 'unobserved' | 'unreadable' | 'durable-off-400';
|
|
102
|
+
export interface InteractiveDetachPosture {
|
|
103
|
+
readonly stamp: boolean;
|
|
104
|
+
readonly reason: InteractiveDetachPostureReason;
|
|
105
|
+
}
|
|
106
|
+
export declare function interactiveDetachPosture(wire: InteractiveEngineWire, input: InteractiveOpeningInput): InteractiveDetachPosture;
|
|
107
|
+
export type InteractiveStreamOptions = {
|
|
108
|
+
transientOk: true;
|
|
109
|
+
signal?: AbortSignal;
|
|
110
|
+
headers?: Record<string, string>;
|
|
111
|
+
onResponse?: (res: Response) => void;
|
|
112
|
+
idempotencyKey?: string | null;
|
|
113
|
+
heartbeatGraceMs?: number;
|
|
114
|
+
};
|
|
115
|
+
export declare function streamInteractiveRun(wire: InteractiveEngineWire, req: TaskRequest, opts: InteractiveStreamOptions, input: InteractiveOpeningInput): AsyncGenerator<AgentEvent>;
|
|
116
|
+
export type BackgroundHandoffVerdict = {
|
|
117
|
+
readonly verdict: 'eligible';
|
|
118
|
+
readonly taskId: string;
|
|
119
|
+
} | {
|
|
120
|
+
readonly verdict: 'ineligible';
|
|
121
|
+
readonly reason: BackgroundHandoffRefusal;
|
|
122
|
+
readonly cause?: InteractiveDetachPostureReason;
|
|
123
|
+
} | {
|
|
124
|
+
readonly verdict: 'unknown';
|
|
125
|
+
readonly reason: BackgroundHandoffUnknown;
|
|
126
|
+
};
|
|
127
|
+
export type BackgroundHandoffRefusal = 'no-run' | 'stream-ended' | 'already-handed-off' | 'finished' | 'engine-replaced' | 'stopping' | 'not-stamped' | 'declined' | 'not-started' | 'awaiting-user';
|
|
128
|
+
export type BackgroundHandoffUnknown = 'unreadable-input' | 'capability-unconfirmed' | 'detach-unconfirmed' | 'awaiting-user-unattributable';
|
|
129
|
+
export interface HoldOwnerView {
|
|
130
|
+
readonly taskId: string | undefined;
|
|
131
|
+
readonly sessionId: string | undefined;
|
|
132
|
+
}
|
|
133
|
+
export interface HandoffJudgeFacts {
|
|
134
|
+
readonly inputReadable: boolean;
|
|
135
|
+
readonly wirePresent: boolean;
|
|
136
|
+
readonly wireRecognized: boolean;
|
|
137
|
+
readonly rec: OpeningRecordView | undefined;
|
|
138
|
+
readonly capability: SessionBackgroundableReading['kind'];
|
|
139
|
+
readonly capsGenerationNow: number | undefined;
|
|
140
|
+
readonly holds: readonly HoldOwnerView[];
|
|
141
|
+
readonly nowMs: number;
|
|
142
|
+
}
|
|
143
|
+
export declare function handoffVerdictOf(f: HandoffJudgeFacts): BackgroundHandoffVerdict;
|
|
144
|
+
export interface HandoffJudgeInput {
|
|
145
|
+
readonly wire: InteractiveEngineWire | undefined;
|
|
146
|
+
readonly sessionKey: string;
|
|
147
|
+
}
|
|
148
|
+
export interface JudgedHandoff {
|
|
149
|
+
readonly verdict: BackgroundHandoffVerdict;
|
|
150
|
+
readonly rec: OpeningRecord | undefined;
|
|
151
|
+
readonly state: WireState | undefined;
|
|
152
|
+
}
|
|
153
|
+
export declare function judgeHandoff(input: HandoffJudgeInput | null | undefined): JudgedHandoff;
|
|
154
|
+
export declare function backgroundHandoffEligibility(input: {
|
|
155
|
+
readonly wire: InteractiveEngineWire | undefined;
|
|
156
|
+
readonly sessionKey: string;
|
|
157
|
+
}): BackgroundHandoffVerdict;
|
|
158
|
+
export declare function backgroundHandoffSentence(v: BackgroundHandoffVerdict, lang?: UiLanguage): string | undefined;
|
|
159
|
+
export interface InteractiveStopFacts {
|
|
160
|
+
readonly detachArmed: boolean;
|
|
161
|
+
readonly handedOff: boolean;
|
|
162
|
+
}
|
|
163
|
+
export declare function interactiveStopFacts(wire: InteractiveEngineWire | undefined, taskId: string): InteractiveStopFacts;
|
|
164
|
+
export declare function noteInteractiveStopRequested(wire: InteractiveEngineWire, taskId: string): 'withheld' | 'proceed';
|
|
165
|
+
export {};
|