@codelia/shared-types 0.1.83 → 0.1.85
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/dist/index.cjs +13 -8
- package/dist/index.d.cts +190 -7
- package/dist/index.d.ts +190 -7
- package/dist/index.js +12 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ATTACHMENT_ID_PATTERN: () => ATTACHMENT_ID_PATTERN,
|
|
23
24
|
IMAGE_REFERENCE_MAX_COUNT: () => IMAGE_REFERENCE_MAX_COUNT,
|
|
24
25
|
MODEL_REASONING_LEVELS: () => MODEL_REASONING_LEVELS,
|
|
25
26
|
SkillCatalogSchema: () => SkillCatalogSchema,
|
|
@@ -35,14 +36,6 @@ __export(index_exports, {
|
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(index_exports);
|
|
37
38
|
|
|
38
|
-
// src/image-artifact.ts
|
|
39
|
-
var IMAGE_REFERENCE_MAX_COUNT = 16;
|
|
40
|
-
function isImageModelView(value) {
|
|
41
|
-
if (!value || typeof value !== "object") return false;
|
|
42
|
-
const view = value;
|
|
43
|
-
return view.version === "jpeg-q90-444-v1" && view.media_type === "image/jpeg" && typeof view.sha256 === "string" && /^[0-9a-f]{64}$/.test(view.sha256) && typeof view.byte_size === "number" && Number.isSafeInteger(view.byte_size) && view.byte_size > 0 && view.byte_size <= 8 * 1024 * 1024;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
39
|
// src/approval.ts
|
|
47
40
|
var parseApprovalMode = (value) => {
|
|
48
41
|
if (value === "minimal" || value === "trusted" || value === "full-access") {
|
|
@@ -51,6 +44,17 @@ var parseApprovalMode = (value) => {
|
|
|
51
44
|
return void 0;
|
|
52
45
|
};
|
|
53
46
|
|
|
47
|
+
// src/attachment.ts
|
|
48
|
+
var ATTACHMENT_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
49
|
+
|
|
50
|
+
// src/image-artifact.ts
|
|
51
|
+
var IMAGE_REFERENCE_MAX_COUNT = 16;
|
|
52
|
+
function isImageModelView(value) {
|
|
53
|
+
if (!value || typeof value !== "object") return false;
|
|
54
|
+
const view = value;
|
|
55
|
+
return view.version === "jpeg-q90-444-v1" && view.media_type === "image/jpeg" && typeof view.sha256 === "string" && /^[0-9a-f]{64}$/.test(view.sha256) && typeof view.byte_size === "number" && Number.isSafeInteger(view.byte_size) && view.byte_size > 0 && view.byte_size <= 32 * 1024 * 1024;
|
|
56
|
+
}
|
|
57
|
+
|
|
54
58
|
// src/model.ts
|
|
55
59
|
var isModelFastMode = (value) => typeof value === "boolean" || value === "ultrafast";
|
|
56
60
|
var MODEL_REASONING_LEVELS = [
|
|
@@ -96,6 +100,7 @@ var SkillSearchResultSchema = import_zod.z.object({
|
|
|
96
100
|
}).strict();
|
|
97
101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
98
102
|
0 && (module.exports = {
|
|
103
|
+
ATTACHMENT_ID_PATTERN,
|
|
99
104
|
IMAGE_REFERENCE_MAX_COUNT,
|
|
100
105
|
MODEL_REASONING_LEVELS,
|
|
101
106
|
SkillCatalogSchema,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
type ApprovalMode = "minimal" | "trusted" | "full-access";
|
|
4
|
+
declare const parseApprovalMode: (value: unknown) => ApprovalMode | undefined;
|
|
5
|
+
|
|
6
|
+
declare const ATTACHMENT_ID_PATTERN: RegExp;
|
|
7
|
+
/** Immutable runtime-owned attachment metadata. No source path is retained. */
|
|
8
|
+
type AttachmentRef = {
|
|
9
|
+
attachment_id: string;
|
|
10
|
+
sha256: string;
|
|
11
|
+
byte_size: number;
|
|
12
|
+
media_type: string;
|
|
13
|
+
display_name: string;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
origin?: "file" | "clipboard_image";
|
|
17
|
+
};
|
|
18
|
+
|
|
3
19
|
/** Persistence/schema safety ceiling, not a provider capability promise. */
|
|
4
20
|
declare const IMAGE_REFERENCE_MAX_COUNT = 16;
|
|
5
21
|
type ImageMediaType = "image/png" | "image/jpeg" | "image/webp" | "image/gif";
|
|
@@ -23,7 +39,7 @@ type ImageArtifactRef = {
|
|
|
23
39
|
};
|
|
24
40
|
type GeneratedImageMetadata = ImageArtifactRef & {
|
|
25
41
|
kind?: "generated";
|
|
26
|
-
media_type: "image/png";
|
|
42
|
+
media_type: "image/png" | "image/jpeg";
|
|
27
43
|
created_at: string;
|
|
28
44
|
provider: string;
|
|
29
45
|
requested_model: string;
|
|
@@ -42,10 +58,77 @@ type AttachedImageMetadata = ImageArtifactRef & {
|
|
|
42
58
|
};
|
|
43
59
|
type ImageArtifactMetadata = GeneratedImageMetadata | AttachedImageMetadata;
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Message Content Parts
|
|
63
|
+
*/
|
|
64
|
+
type ImageRefPart = {
|
|
65
|
+
type: "image_ref";
|
|
66
|
+
image_ref: ImageArtifactRef;
|
|
67
|
+
detail?: "auto" | "low" | "high";
|
|
68
|
+
};
|
|
69
|
+
type AttachmentRefPart = {
|
|
70
|
+
type: "attachment_ref";
|
|
71
|
+
attachment_ref: AttachmentRef;
|
|
72
|
+
image_ref?: ImageArtifactRef;
|
|
73
|
+
};
|
|
74
|
+
type TextPart = {
|
|
75
|
+
type: "text";
|
|
76
|
+
text: string;
|
|
77
|
+
};
|
|
78
|
+
type ImagePart = {
|
|
79
|
+
type: "image_url";
|
|
80
|
+
image_url: {
|
|
81
|
+
url: string;
|
|
82
|
+
detail?: "auto" | "low" | "high";
|
|
83
|
+
media_type?: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type DocumentPart = {
|
|
87
|
+
type: "document";
|
|
88
|
+
source: {
|
|
89
|
+
data: string;
|
|
90
|
+
media_type: "application/pdf";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
type OtherPart = {
|
|
94
|
+
type: "other";
|
|
95
|
+
provider: string;
|
|
96
|
+
kind: string;
|
|
97
|
+
payload: unknown;
|
|
98
|
+
};
|
|
99
|
+
type ContentPart = TextPart | ImagePart | ImageRefPart | AttachmentRefPart | DocumentPart | OtherPart;
|
|
47
100
|
|
|
48
|
-
type
|
|
101
|
+
type ContextUsageCategory = "system" | "tools" | "messages" | "tool_results" | "images";
|
|
102
|
+
type ContextUsageBreakdownEntry = {
|
|
103
|
+
category: ContextUsageCategory;
|
|
104
|
+
/** Estimated tokens of the current history in this category. */
|
|
105
|
+
tokens: number;
|
|
106
|
+
/** Number of items (images only). */
|
|
107
|
+
count?: number;
|
|
108
|
+
};
|
|
109
|
+
/** Context window usage of one agent; produced by core, sent by runtime. */
|
|
110
|
+
type ContextUsage = {
|
|
111
|
+
/** Null only when no agent has been built yet. */
|
|
112
|
+
provider: string | null;
|
|
113
|
+
model: string | null;
|
|
114
|
+
/** Model input limit (`maxInputTokens ?? contextWindow`); null when unknown. */
|
|
115
|
+
limit_tokens: number | null;
|
|
116
|
+
/** Last provider-reported `total_tokens` (same basis as `left_percent`). */
|
|
117
|
+
used_tokens: number | null;
|
|
118
|
+
/** Last provider-reported `input_tokens`. */
|
|
119
|
+
input_tokens: number | null;
|
|
120
|
+
left_percent: number | null;
|
|
121
|
+
/** `provider`: used/input come from the last model call; `none`: no call yet. */
|
|
122
|
+
basis: "provider" | "none";
|
|
123
|
+
/**
|
|
124
|
+
* Size estimate of the current history and tool definitions by category
|
|
125
|
+
* (serialized bytes / 3; images via the model's image-token estimate). Not
|
|
126
|
+
* normalized to `used_tokens`, which stays provider-reported only.
|
|
127
|
+
*/
|
|
128
|
+
breakdown: ContextUsageBreakdownEntry[];
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
type BuiltinProviderName = "openai" | "anthropic" | "openrouter" | "google" | "deepseek" | "moonshot" | "zai" | "xai";
|
|
49
132
|
/** Runtime endpoint names are configured independently of builtin adapters. */
|
|
50
133
|
type ProviderName = string;
|
|
51
134
|
|
|
@@ -59,6 +142,28 @@ type ReasoningEvent = {
|
|
|
59
142
|
content: string;
|
|
60
143
|
timestamp: number;
|
|
61
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* Provisional, ephemeral text streamed while one model call attempt is in progress.
|
|
147
|
+
* `stream_id` identifies the attempt (a retried call gets a new id). `index` groups
|
|
148
|
+
* provisional blocks of one kind within that stream, numbered in order of their
|
|
149
|
+
* first delta; it does not identify a complete event. When the step's complete
|
|
150
|
+
* events arrive, replace all provisional text of the `stream_id` with them; discard
|
|
151
|
+
* it on `llm.retry` or when the run ends without them. Never persisted or replayed.
|
|
152
|
+
* Opt-in via `ui_capabilities.supports_text_delta`. See ui-protocol.md §5.2.
|
|
153
|
+
*/
|
|
154
|
+
type TextDeltaEvent = {
|
|
155
|
+
type: "text.delta";
|
|
156
|
+
delta: string;
|
|
157
|
+
stream_id: string;
|
|
158
|
+
index: number;
|
|
159
|
+
};
|
|
160
|
+
/** Reasoning counterpart of `TextDeltaEvent`; the complete `reasoning` event stays authoritative. */
|
|
161
|
+
type ReasoningDeltaEvent = {
|
|
162
|
+
type: "reasoning.delta";
|
|
163
|
+
delta: string;
|
|
164
|
+
stream_id: string;
|
|
165
|
+
index: number;
|
|
166
|
+
};
|
|
62
167
|
type LlmRetryEvent = {
|
|
63
168
|
type: "llm.retry";
|
|
64
169
|
provider: ProviderName;
|
|
@@ -138,12 +243,18 @@ type HiddenUserMessageEvent = {
|
|
|
138
243
|
type: "hidden_user_message";
|
|
139
244
|
content: string;
|
|
140
245
|
};
|
|
246
|
+
type SteerAppliedEvent = {
|
|
247
|
+
type: "steer_applied";
|
|
248
|
+
steer_id: string;
|
|
249
|
+
content: string | ContentPart[];
|
|
250
|
+
timestamp: number;
|
|
251
|
+
};
|
|
141
252
|
type FinalResponseEvent = {
|
|
142
253
|
type: "final";
|
|
143
254
|
content: string;
|
|
144
255
|
termination_reason?: "normal" | "max_steps" | "permission_denied";
|
|
145
256
|
};
|
|
146
|
-
type AgentEvent = TextEvent | ReasoningEvent | LlmRetryEvent | LlmStatusEvent | StepStartEvent | ToolCallEvent | ToolResultEvent | PermissionPreviewEvent | PermissionReadyEvent | StepCompleteEvent | CompactionStartEvent | CompactionCompleteEvent | HiddenUserMessageEvent | FinalResponseEvent;
|
|
257
|
+
type AgentEvent = TextEvent | ReasoningEvent | TextDeltaEvent | ReasoningDeltaEvent | LlmRetryEvent | LlmStatusEvent | StepStartEvent | ToolCallEvent | ToolResultEvent | PermissionPreviewEvent | PermissionReadyEvent | StepCompleteEvent | CompactionStartEvent | CompactionCompleteEvent | HiddenUserMessageEvent | SteerAppliedEvent | FinalResponseEvent;
|
|
147
258
|
|
|
148
259
|
/** Observed successful stream timing, measured with a monotonic clock. */
|
|
149
260
|
type LlmCallTiming = {
|
|
@@ -151,7 +262,7 @@ type LlmCallTiming = {
|
|
|
151
262
|
generation_duration_ms: number;
|
|
152
263
|
/** Optional observed start of hidden reasoning, distinct from first delta. */
|
|
153
264
|
generation_start_ms?: number;
|
|
154
|
-
generation_start_source?: "reasoning_item";
|
|
265
|
+
generation_start_source?: "reasoning_item" | "thought_step";
|
|
155
266
|
};
|
|
156
267
|
|
|
157
268
|
/** Explicit speed selection; booleans preserve the original fast-mode contract. */
|
|
@@ -161,6 +272,20 @@ declare const MODEL_REASONING_LEVELS: readonly ["low", "medium", "high", "xhigh"
|
|
|
161
272
|
type ModelReasoningLevel = (typeof MODEL_REASONING_LEVELS)[number];
|
|
162
273
|
declare const isModelReasoningLevel: (value: string) => value is ModelReasoningLevel;
|
|
163
274
|
|
|
275
|
+
/** Safe failure-only context for status notifications and retained errors. */
|
|
276
|
+
type RunErrorInfo = {
|
|
277
|
+
name: string;
|
|
278
|
+
message: string;
|
|
279
|
+
provider?: ProviderName;
|
|
280
|
+
kind?: string;
|
|
281
|
+
status?: number;
|
|
282
|
+
code?: string;
|
|
283
|
+
attempts?: number;
|
|
284
|
+
max_attempts?: number;
|
|
285
|
+
detail?: string;
|
|
286
|
+
hint?: string;
|
|
287
|
+
};
|
|
288
|
+
|
|
164
289
|
type SessionStateSummary = {
|
|
165
290
|
session_id: string;
|
|
166
291
|
updated_at: string;
|
|
@@ -168,6 +293,8 @@ type SessionStateSummary = {
|
|
|
168
293
|
message_count?: number;
|
|
169
294
|
last_user_message?: string;
|
|
170
295
|
workspace_root?: string;
|
|
296
|
+
pinned?: boolean;
|
|
297
|
+
archived_at?: string;
|
|
171
298
|
};
|
|
172
299
|
|
|
173
300
|
declare const SkillScopeSchema: z.ZodEnum<{
|
|
@@ -263,6 +390,29 @@ type TaskUsage = {
|
|
|
263
390
|
total_tokens: number;
|
|
264
391
|
total_cost_usd?: number | null;
|
|
265
392
|
};
|
|
393
|
+
/**
|
|
394
|
+
* Parent-visible progress of a running subagent. Counts, phase and tool names
|
|
395
|
+
* only; arguments and results stay in the child session.
|
|
396
|
+
*/
|
|
397
|
+
type TaskProgress = {
|
|
398
|
+
/** Model calls started so far (1-based once the first call starts). */
|
|
399
|
+
step: number;
|
|
400
|
+
max_steps?: number;
|
|
401
|
+
phase: "model" | "tool" | "compacting" | "finishing";
|
|
402
|
+
current_tool?: {
|
|
403
|
+
name: string;
|
|
404
|
+
tool_call_id: string;
|
|
405
|
+
started_at: string;
|
|
406
|
+
};
|
|
407
|
+
last_tool?: {
|
|
408
|
+
name: string;
|
|
409
|
+
status: "ok" | "error";
|
|
410
|
+
finished_at: string;
|
|
411
|
+
};
|
|
412
|
+
/** Tool calls requested so far. */
|
|
413
|
+
tool_calls: number;
|
|
414
|
+
updated_at: string;
|
|
415
|
+
};
|
|
266
416
|
/** Stored peer content is untrusted; accepted does not mean acted on by a model. */
|
|
267
417
|
type AgentMessage = {
|
|
268
418
|
message_id: string;
|
|
@@ -274,4 +424,37 @@ type AgentMessage = {
|
|
|
274
424
|
content: string;
|
|
275
425
|
};
|
|
276
426
|
|
|
277
|
-
|
|
427
|
+
type GoalStatus = "active" | "paused" | "blocked" | "usage_limited" | "budget_limited" | "complete";
|
|
428
|
+
type GoalStopReason = "user" | "turn_limit" | "run_error" | "checkpoint_failed" | "interrupted" | "blocker";
|
|
429
|
+
type GoalRecord = {
|
|
430
|
+
session_id: string;
|
|
431
|
+
goal_id: string;
|
|
432
|
+
revision: number;
|
|
433
|
+
objective: string;
|
|
434
|
+
status: GoalStatus;
|
|
435
|
+
stop_reason?: GoalStopReason;
|
|
436
|
+
stop_detail?: string;
|
|
437
|
+
token_budget: number | null;
|
|
438
|
+
tokens_used: number;
|
|
439
|
+
usage_known: boolean;
|
|
440
|
+
activation_id: string;
|
|
441
|
+
automatic_runs: number;
|
|
442
|
+
created_at: string;
|
|
443
|
+
updated_at: string;
|
|
444
|
+
};
|
|
445
|
+
type GoalSnapshot = {
|
|
446
|
+
session_id: string | null;
|
|
447
|
+
goal: GoalRecord | null;
|
|
448
|
+
can_continue: boolean;
|
|
449
|
+
accepted_run_id?: string;
|
|
450
|
+
active_run_id?: string;
|
|
451
|
+
};
|
|
452
|
+
type GoalOffer = {
|
|
453
|
+
session_id: string;
|
|
454
|
+
goal_id: string;
|
|
455
|
+
revision: number;
|
|
456
|
+
continuation_id: string;
|
|
457
|
+
after_run_id?: string;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
export { ATTACHMENT_ID_PATTERN, type AgentEvent, type AgentMessage, type ApprovalMode, type AttachedImageMetadata, type AttachmentRef, type AttachmentRefPart, type BuiltinProviderName, type CompactionCompleteEvent, type CompactionStartEvent, type ContentPart, type ContextUsage, type ContextUsageBreakdownEntry, type ContextUsageCategory, type DocumentPart, type FinalResponseEvent, type GeneratedImageMetadata, type GoalOffer, type GoalRecord, type GoalSnapshot, type GoalStatus, type GoalStopReason, type HiddenUserMessageEvent, IMAGE_REFERENCE_MAX_COUNT, type ImageArtifactMetadata, type ImageArtifactRef, type ImageMediaType, type ImageModelView, type ImagePart, type ImageRefPart, type LlmCallTiming, type LlmRetryEvent, type LlmStatusEvent, MODEL_REASONING_LEVELS, type ModelFastMode, type ModelReasoningLevel, type OtherPart, type PermissionPreviewEvent, type PermissionReadyEvent, type ProviderName, type ReasoningDeltaEvent, type ReasoningEvent, type RunErrorInfo, type SessionStateSummary, type SkillCatalog, SkillCatalogSchema, type SkillLoadError, SkillLoadErrorSchema, type SkillMetadata, SkillMetadataSchema, type SkillScope, SkillScopeSchema, type SkillSearchReason, SkillSearchReasonSchema, type SkillSearchResult, SkillSearchResultSchema, type SteerAppliedEvent, type StepCompleteEvent, type StepStartEvent, type SubagentLineage, type TaskProgress, type TaskTerminationReason, type TaskUsage, type TextDeltaEvent, type TextEvent, type TextPart, type ToolCallEvent, type ToolResultEvent, isImageModelView, isModelFastMode, isModelReasoningLevel, parseApprovalMode };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
type ApprovalMode = "minimal" | "trusted" | "full-access";
|
|
4
|
+
declare const parseApprovalMode: (value: unknown) => ApprovalMode | undefined;
|
|
5
|
+
|
|
6
|
+
declare const ATTACHMENT_ID_PATTERN: RegExp;
|
|
7
|
+
/** Immutable runtime-owned attachment metadata. No source path is retained. */
|
|
8
|
+
type AttachmentRef = {
|
|
9
|
+
attachment_id: string;
|
|
10
|
+
sha256: string;
|
|
11
|
+
byte_size: number;
|
|
12
|
+
media_type: string;
|
|
13
|
+
display_name: string;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
origin?: "file" | "clipboard_image";
|
|
17
|
+
};
|
|
18
|
+
|
|
3
19
|
/** Persistence/schema safety ceiling, not a provider capability promise. */
|
|
4
20
|
declare const IMAGE_REFERENCE_MAX_COUNT = 16;
|
|
5
21
|
type ImageMediaType = "image/png" | "image/jpeg" | "image/webp" | "image/gif";
|
|
@@ -23,7 +39,7 @@ type ImageArtifactRef = {
|
|
|
23
39
|
};
|
|
24
40
|
type GeneratedImageMetadata = ImageArtifactRef & {
|
|
25
41
|
kind?: "generated";
|
|
26
|
-
media_type: "image/png";
|
|
42
|
+
media_type: "image/png" | "image/jpeg";
|
|
27
43
|
created_at: string;
|
|
28
44
|
provider: string;
|
|
29
45
|
requested_model: string;
|
|
@@ -42,10 +58,77 @@ type AttachedImageMetadata = ImageArtifactRef & {
|
|
|
42
58
|
};
|
|
43
59
|
type ImageArtifactMetadata = GeneratedImageMetadata | AttachedImageMetadata;
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Message Content Parts
|
|
63
|
+
*/
|
|
64
|
+
type ImageRefPart = {
|
|
65
|
+
type: "image_ref";
|
|
66
|
+
image_ref: ImageArtifactRef;
|
|
67
|
+
detail?: "auto" | "low" | "high";
|
|
68
|
+
};
|
|
69
|
+
type AttachmentRefPart = {
|
|
70
|
+
type: "attachment_ref";
|
|
71
|
+
attachment_ref: AttachmentRef;
|
|
72
|
+
image_ref?: ImageArtifactRef;
|
|
73
|
+
};
|
|
74
|
+
type TextPart = {
|
|
75
|
+
type: "text";
|
|
76
|
+
text: string;
|
|
77
|
+
};
|
|
78
|
+
type ImagePart = {
|
|
79
|
+
type: "image_url";
|
|
80
|
+
image_url: {
|
|
81
|
+
url: string;
|
|
82
|
+
detail?: "auto" | "low" | "high";
|
|
83
|
+
media_type?: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type DocumentPart = {
|
|
87
|
+
type: "document";
|
|
88
|
+
source: {
|
|
89
|
+
data: string;
|
|
90
|
+
media_type: "application/pdf";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
type OtherPart = {
|
|
94
|
+
type: "other";
|
|
95
|
+
provider: string;
|
|
96
|
+
kind: string;
|
|
97
|
+
payload: unknown;
|
|
98
|
+
};
|
|
99
|
+
type ContentPart = TextPart | ImagePart | ImageRefPart | AttachmentRefPart | DocumentPart | OtherPart;
|
|
47
100
|
|
|
48
|
-
type
|
|
101
|
+
type ContextUsageCategory = "system" | "tools" | "messages" | "tool_results" | "images";
|
|
102
|
+
type ContextUsageBreakdownEntry = {
|
|
103
|
+
category: ContextUsageCategory;
|
|
104
|
+
/** Estimated tokens of the current history in this category. */
|
|
105
|
+
tokens: number;
|
|
106
|
+
/** Number of items (images only). */
|
|
107
|
+
count?: number;
|
|
108
|
+
};
|
|
109
|
+
/** Context window usage of one agent; produced by core, sent by runtime. */
|
|
110
|
+
type ContextUsage = {
|
|
111
|
+
/** Null only when no agent has been built yet. */
|
|
112
|
+
provider: string | null;
|
|
113
|
+
model: string | null;
|
|
114
|
+
/** Model input limit (`maxInputTokens ?? contextWindow`); null when unknown. */
|
|
115
|
+
limit_tokens: number | null;
|
|
116
|
+
/** Last provider-reported `total_tokens` (same basis as `left_percent`). */
|
|
117
|
+
used_tokens: number | null;
|
|
118
|
+
/** Last provider-reported `input_tokens`. */
|
|
119
|
+
input_tokens: number | null;
|
|
120
|
+
left_percent: number | null;
|
|
121
|
+
/** `provider`: used/input come from the last model call; `none`: no call yet. */
|
|
122
|
+
basis: "provider" | "none";
|
|
123
|
+
/**
|
|
124
|
+
* Size estimate of the current history and tool definitions by category
|
|
125
|
+
* (serialized bytes / 3; images via the model's image-token estimate). Not
|
|
126
|
+
* normalized to `used_tokens`, which stays provider-reported only.
|
|
127
|
+
*/
|
|
128
|
+
breakdown: ContextUsageBreakdownEntry[];
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
type BuiltinProviderName = "openai" | "anthropic" | "openrouter" | "google" | "deepseek" | "moonshot" | "zai" | "xai";
|
|
49
132
|
/** Runtime endpoint names are configured independently of builtin adapters. */
|
|
50
133
|
type ProviderName = string;
|
|
51
134
|
|
|
@@ -59,6 +142,28 @@ type ReasoningEvent = {
|
|
|
59
142
|
content: string;
|
|
60
143
|
timestamp: number;
|
|
61
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* Provisional, ephemeral text streamed while one model call attempt is in progress.
|
|
147
|
+
* `stream_id` identifies the attempt (a retried call gets a new id). `index` groups
|
|
148
|
+
* provisional blocks of one kind within that stream, numbered in order of their
|
|
149
|
+
* first delta; it does not identify a complete event. When the step's complete
|
|
150
|
+
* events arrive, replace all provisional text of the `stream_id` with them; discard
|
|
151
|
+
* it on `llm.retry` or when the run ends without them. Never persisted or replayed.
|
|
152
|
+
* Opt-in via `ui_capabilities.supports_text_delta`. See ui-protocol.md §5.2.
|
|
153
|
+
*/
|
|
154
|
+
type TextDeltaEvent = {
|
|
155
|
+
type: "text.delta";
|
|
156
|
+
delta: string;
|
|
157
|
+
stream_id: string;
|
|
158
|
+
index: number;
|
|
159
|
+
};
|
|
160
|
+
/** Reasoning counterpart of `TextDeltaEvent`; the complete `reasoning` event stays authoritative. */
|
|
161
|
+
type ReasoningDeltaEvent = {
|
|
162
|
+
type: "reasoning.delta";
|
|
163
|
+
delta: string;
|
|
164
|
+
stream_id: string;
|
|
165
|
+
index: number;
|
|
166
|
+
};
|
|
62
167
|
type LlmRetryEvent = {
|
|
63
168
|
type: "llm.retry";
|
|
64
169
|
provider: ProviderName;
|
|
@@ -138,12 +243,18 @@ type HiddenUserMessageEvent = {
|
|
|
138
243
|
type: "hidden_user_message";
|
|
139
244
|
content: string;
|
|
140
245
|
};
|
|
246
|
+
type SteerAppliedEvent = {
|
|
247
|
+
type: "steer_applied";
|
|
248
|
+
steer_id: string;
|
|
249
|
+
content: string | ContentPart[];
|
|
250
|
+
timestamp: number;
|
|
251
|
+
};
|
|
141
252
|
type FinalResponseEvent = {
|
|
142
253
|
type: "final";
|
|
143
254
|
content: string;
|
|
144
255
|
termination_reason?: "normal" | "max_steps" | "permission_denied";
|
|
145
256
|
};
|
|
146
|
-
type AgentEvent = TextEvent | ReasoningEvent | LlmRetryEvent | LlmStatusEvent | StepStartEvent | ToolCallEvent | ToolResultEvent | PermissionPreviewEvent | PermissionReadyEvent | StepCompleteEvent | CompactionStartEvent | CompactionCompleteEvent | HiddenUserMessageEvent | FinalResponseEvent;
|
|
257
|
+
type AgentEvent = TextEvent | ReasoningEvent | TextDeltaEvent | ReasoningDeltaEvent | LlmRetryEvent | LlmStatusEvent | StepStartEvent | ToolCallEvent | ToolResultEvent | PermissionPreviewEvent | PermissionReadyEvent | StepCompleteEvent | CompactionStartEvent | CompactionCompleteEvent | HiddenUserMessageEvent | SteerAppliedEvent | FinalResponseEvent;
|
|
147
258
|
|
|
148
259
|
/** Observed successful stream timing, measured with a monotonic clock. */
|
|
149
260
|
type LlmCallTiming = {
|
|
@@ -151,7 +262,7 @@ type LlmCallTiming = {
|
|
|
151
262
|
generation_duration_ms: number;
|
|
152
263
|
/** Optional observed start of hidden reasoning, distinct from first delta. */
|
|
153
264
|
generation_start_ms?: number;
|
|
154
|
-
generation_start_source?: "reasoning_item";
|
|
265
|
+
generation_start_source?: "reasoning_item" | "thought_step";
|
|
155
266
|
};
|
|
156
267
|
|
|
157
268
|
/** Explicit speed selection; booleans preserve the original fast-mode contract. */
|
|
@@ -161,6 +272,20 @@ declare const MODEL_REASONING_LEVELS: readonly ["low", "medium", "high", "xhigh"
|
|
|
161
272
|
type ModelReasoningLevel = (typeof MODEL_REASONING_LEVELS)[number];
|
|
162
273
|
declare const isModelReasoningLevel: (value: string) => value is ModelReasoningLevel;
|
|
163
274
|
|
|
275
|
+
/** Safe failure-only context for status notifications and retained errors. */
|
|
276
|
+
type RunErrorInfo = {
|
|
277
|
+
name: string;
|
|
278
|
+
message: string;
|
|
279
|
+
provider?: ProviderName;
|
|
280
|
+
kind?: string;
|
|
281
|
+
status?: number;
|
|
282
|
+
code?: string;
|
|
283
|
+
attempts?: number;
|
|
284
|
+
max_attempts?: number;
|
|
285
|
+
detail?: string;
|
|
286
|
+
hint?: string;
|
|
287
|
+
};
|
|
288
|
+
|
|
164
289
|
type SessionStateSummary = {
|
|
165
290
|
session_id: string;
|
|
166
291
|
updated_at: string;
|
|
@@ -168,6 +293,8 @@ type SessionStateSummary = {
|
|
|
168
293
|
message_count?: number;
|
|
169
294
|
last_user_message?: string;
|
|
170
295
|
workspace_root?: string;
|
|
296
|
+
pinned?: boolean;
|
|
297
|
+
archived_at?: string;
|
|
171
298
|
};
|
|
172
299
|
|
|
173
300
|
declare const SkillScopeSchema: z.ZodEnum<{
|
|
@@ -263,6 +390,29 @@ type TaskUsage = {
|
|
|
263
390
|
total_tokens: number;
|
|
264
391
|
total_cost_usd?: number | null;
|
|
265
392
|
};
|
|
393
|
+
/**
|
|
394
|
+
* Parent-visible progress of a running subagent. Counts, phase and tool names
|
|
395
|
+
* only; arguments and results stay in the child session.
|
|
396
|
+
*/
|
|
397
|
+
type TaskProgress = {
|
|
398
|
+
/** Model calls started so far (1-based once the first call starts). */
|
|
399
|
+
step: number;
|
|
400
|
+
max_steps?: number;
|
|
401
|
+
phase: "model" | "tool" | "compacting" | "finishing";
|
|
402
|
+
current_tool?: {
|
|
403
|
+
name: string;
|
|
404
|
+
tool_call_id: string;
|
|
405
|
+
started_at: string;
|
|
406
|
+
};
|
|
407
|
+
last_tool?: {
|
|
408
|
+
name: string;
|
|
409
|
+
status: "ok" | "error";
|
|
410
|
+
finished_at: string;
|
|
411
|
+
};
|
|
412
|
+
/** Tool calls requested so far. */
|
|
413
|
+
tool_calls: number;
|
|
414
|
+
updated_at: string;
|
|
415
|
+
};
|
|
266
416
|
/** Stored peer content is untrusted; accepted does not mean acted on by a model. */
|
|
267
417
|
type AgentMessage = {
|
|
268
418
|
message_id: string;
|
|
@@ -274,4 +424,37 @@ type AgentMessage = {
|
|
|
274
424
|
content: string;
|
|
275
425
|
};
|
|
276
426
|
|
|
277
|
-
|
|
427
|
+
type GoalStatus = "active" | "paused" | "blocked" | "usage_limited" | "budget_limited" | "complete";
|
|
428
|
+
type GoalStopReason = "user" | "turn_limit" | "run_error" | "checkpoint_failed" | "interrupted" | "blocker";
|
|
429
|
+
type GoalRecord = {
|
|
430
|
+
session_id: string;
|
|
431
|
+
goal_id: string;
|
|
432
|
+
revision: number;
|
|
433
|
+
objective: string;
|
|
434
|
+
status: GoalStatus;
|
|
435
|
+
stop_reason?: GoalStopReason;
|
|
436
|
+
stop_detail?: string;
|
|
437
|
+
token_budget: number | null;
|
|
438
|
+
tokens_used: number;
|
|
439
|
+
usage_known: boolean;
|
|
440
|
+
activation_id: string;
|
|
441
|
+
automatic_runs: number;
|
|
442
|
+
created_at: string;
|
|
443
|
+
updated_at: string;
|
|
444
|
+
};
|
|
445
|
+
type GoalSnapshot = {
|
|
446
|
+
session_id: string | null;
|
|
447
|
+
goal: GoalRecord | null;
|
|
448
|
+
can_continue: boolean;
|
|
449
|
+
accepted_run_id?: string;
|
|
450
|
+
active_run_id?: string;
|
|
451
|
+
};
|
|
452
|
+
type GoalOffer = {
|
|
453
|
+
session_id: string;
|
|
454
|
+
goal_id: string;
|
|
455
|
+
revision: number;
|
|
456
|
+
continuation_id: string;
|
|
457
|
+
after_run_id?: string;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
export { ATTACHMENT_ID_PATTERN, type AgentEvent, type AgentMessage, type ApprovalMode, type AttachedImageMetadata, type AttachmentRef, type AttachmentRefPart, type BuiltinProviderName, type CompactionCompleteEvent, type CompactionStartEvent, type ContentPart, type ContextUsage, type ContextUsageBreakdownEntry, type ContextUsageCategory, type DocumentPart, type FinalResponseEvent, type GeneratedImageMetadata, type GoalOffer, type GoalRecord, type GoalSnapshot, type GoalStatus, type GoalStopReason, type HiddenUserMessageEvent, IMAGE_REFERENCE_MAX_COUNT, type ImageArtifactMetadata, type ImageArtifactRef, type ImageMediaType, type ImageModelView, type ImagePart, type ImageRefPart, type LlmCallTiming, type LlmRetryEvent, type LlmStatusEvent, MODEL_REASONING_LEVELS, type ModelFastMode, type ModelReasoningLevel, type OtherPart, type PermissionPreviewEvent, type PermissionReadyEvent, type ProviderName, type ReasoningDeltaEvent, type ReasoningEvent, type RunErrorInfo, type SessionStateSummary, type SkillCatalog, SkillCatalogSchema, type SkillLoadError, SkillLoadErrorSchema, type SkillMetadata, SkillMetadataSchema, type SkillScope, SkillScopeSchema, type SkillSearchReason, SkillSearchReasonSchema, type SkillSearchResult, SkillSearchResultSchema, type SteerAppliedEvent, type StepCompleteEvent, type StepStartEvent, type SubagentLineage, type TaskProgress, type TaskTerminationReason, type TaskUsage, type TextDeltaEvent, type TextEvent, type TextPart, type ToolCallEvent, type ToolResultEvent, isImageModelView, isModelFastMode, isModelReasoningLevel, parseApprovalMode };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
// src/image-artifact.ts
|
|
2
|
-
var IMAGE_REFERENCE_MAX_COUNT = 16;
|
|
3
|
-
function isImageModelView(value) {
|
|
4
|
-
if (!value || typeof value !== "object") return false;
|
|
5
|
-
const view = value;
|
|
6
|
-
return view.version === "jpeg-q90-444-v1" && view.media_type === "image/jpeg" && typeof view.sha256 === "string" && /^[0-9a-f]{64}$/.test(view.sha256) && typeof view.byte_size === "number" && Number.isSafeInteger(view.byte_size) && view.byte_size > 0 && view.byte_size <= 8 * 1024 * 1024;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
1
|
// src/approval.ts
|
|
10
2
|
var parseApprovalMode = (value) => {
|
|
11
3
|
if (value === "minimal" || value === "trusted" || value === "full-access") {
|
|
@@ -14,6 +6,17 @@ var parseApprovalMode = (value) => {
|
|
|
14
6
|
return void 0;
|
|
15
7
|
};
|
|
16
8
|
|
|
9
|
+
// src/attachment.ts
|
|
10
|
+
var ATTACHMENT_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
11
|
+
|
|
12
|
+
// src/image-artifact.ts
|
|
13
|
+
var IMAGE_REFERENCE_MAX_COUNT = 16;
|
|
14
|
+
function isImageModelView(value) {
|
|
15
|
+
if (!value || typeof value !== "object") return false;
|
|
16
|
+
const view = value;
|
|
17
|
+
return view.version === "jpeg-q90-444-v1" && view.media_type === "image/jpeg" && typeof view.sha256 === "string" && /^[0-9a-f]{64}$/.test(view.sha256) && typeof view.byte_size === "number" && Number.isSafeInteger(view.byte_size) && view.byte_size > 0 && view.byte_size <= 32 * 1024 * 1024;
|
|
18
|
+
}
|
|
19
|
+
|
|
17
20
|
// src/model.ts
|
|
18
21
|
var isModelFastMode = (value) => typeof value === "boolean" || value === "ultrafast";
|
|
19
22
|
var MODEL_REASONING_LEVELS = [
|
|
@@ -58,6 +61,7 @@ var SkillSearchResultSchema = z.object({
|
|
|
58
61
|
reason: SkillSearchReasonSchema
|
|
59
62
|
}).strict();
|
|
60
63
|
export {
|
|
64
|
+
ATTACHMENT_ID_PATTERN,
|
|
61
65
|
IMAGE_REFERENCE_MAX_COUNT,
|
|
62
66
|
MODEL_REASONING_LEVELS,
|
|
63
67
|
SkillCatalogSchema,
|