@cjhyy/code-shell-pet 0.8.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/README.md +99 -0
- package/dist/capability.d.ts +15 -0
- package/dist/capability.js +251 -0
- package/dist/current-time.d.ts +5 -0
- package/dist/current-time.js +43 -0
- package/dist/delegate-work.d.ts +7 -0
- package/dist/delegate-work.js +142 -0
- package/dist/delegation.d.ts +33 -0
- package/dist/delegation.js +6 -0
- package/dist/disclosure/catalog.d.ts +22 -0
- package/dist/disclosure/catalog.js +104 -0
- package/dist/disclosure/constants.d.ts +7 -0
- package/dist/disclosure/constants.js +7 -0
- package/dist/disclosure/jsonl.d.ts +9 -0
- package/dist/disclosure/jsonl.js +61 -0
- package/dist/disclosure/latest-result.d.ts +8 -0
- package/dist/disclosure/latest-result.js +35 -0
- package/dist/disclosure/search.d.ts +21 -0
- package/dist/disclosure/search.js +124 -0
- package/dist/disclosure/selector.d.ts +2 -0
- package/dist/disclosure/selector.js +5 -0
- package/dist/disclosure/todo-snapshot.d.ts +8 -0
- package/dist/disclosure/todo-snapshot.js +54 -0
- package/dist/follow-ups.d.ts +21 -0
- package/dist/follow-ups.js +102 -0
- package/dist/gateway.d.ts +41 -0
- package/dist/gateway.js +263 -0
- package/dist/host-actions.d.ts +51 -0
- package/dist/host-actions.js +405 -0
- package/dist/index.capability.d.ts +7 -0
- package/dist/index.capability.js +7 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.disclosure.d.ts +13 -0
- package/dist/index.disclosure.js +13 -0
- package/dist/index.js +32 -0
- package/dist/index.protocol.d.ts +8 -0
- package/dist/index.protocol.js +8 -0
- package/dist/index.team.d.ts +2 -0
- package/dist/index.team.js +2 -0
- package/dist/long-task.d.ts +251 -0
- package/dist/long-task.js +795 -0
- package/dist/mobile-remote.d.ts +14 -0
- package/dist/mobile-remote.js +39 -0
- package/dist/outbound-message.d.ts +15 -0
- package/dist/outbound-message.js +127 -0
- package/dist/pending-decision-index.d.ts +24 -0
- package/dist/pending-decision-index.js +110 -0
- package/dist/profile.d.ts +27 -0
- package/dist/profile.js +120 -0
- package/dist/projection-extension.d.ts +8 -0
- package/dist/projection-extension.js +238 -0
- package/dist/protocol.d.ts +58 -0
- package/dist/protocol.js +15 -0
- package/dist/report-to-mimi.d.ts +7 -0
- package/dist/report-to-mimi.js +87 -0
- package/dist/run-params.d.ts +34 -0
- package/dist/run-params.js +387 -0
- package/dist/segment-closure.d.ts +52 -0
- package/dist/segment-closure.js +130 -0
- package/dist/session-control.d.ts +5 -0
- package/dist/session-control.js +46 -0
- package/dist/session-index.d.ts +22 -0
- package/dist/session-index.js +324 -0
- package/dist/sessions-tool.d.ts +21 -0
- package/dist/sessions-tool.js +145 -0
- package/dist/team.d.ts +13 -0
- package/dist/team.js +38 -0
- package/dist/tool-arguments.d.ts +1 -0
- package/dist/tool-arguments.js +10 -0
- package/dist/topic-segment.d.ts +55 -0
- package/dist/topic-segment.js +37 -0
- package/dist/types.d.ts +95 -0
- package/dist/types.js +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable Pet long-task domain model.
|
|
3
|
+
*
|
|
4
|
+
* The package owns the state machine and the bounded context contract. Hosts
|
|
5
|
+
* own persistence, worker control, and UI transport. Keeping those effects out
|
|
6
|
+
* of this module lets Desktop and a future headless host share identical task
|
|
7
|
+
* semantics without teaching core about Pet.
|
|
8
|
+
*/
|
|
9
|
+
import type { PetWorkExecutionBackend } from "./delegation.js";
|
|
10
|
+
export declare const PET_LONG_TASK_SCHEMA_VERSION: 1;
|
|
11
|
+
export declare const MAX_PET_LONG_TASK_EVENTS = 120;
|
|
12
|
+
export declare const MAX_PET_LONG_TASK_SUMMARY_LENGTH = 8000;
|
|
13
|
+
export type PetLongTaskStatus = "queued" | "running" | "waiting" | "paused" | "interrupted" | "completed" | "failed" | "cancelled";
|
|
14
|
+
export type PetLongTaskPhase = "planning" | "executing" | "waiting-user" | "waiting-worker" | "finalizing";
|
|
15
|
+
export type PetLongTaskVerificationMode = "turn" | "goal";
|
|
16
|
+
export interface PetLongTaskArtifact {
|
|
17
|
+
kind: "session" | "result" | "file" | "url";
|
|
18
|
+
label: string;
|
|
19
|
+
/** Opaque host reference. The Pet package never dereferences it. */
|
|
20
|
+
reference: string;
|
|
21
|
+
}
|
|
22
|
+
/** Host-owned delivery route for a proactive completion receipt. */
|
|
23
|
+
export interface PetLongTaskCompletionTarget {
|
|
24
|
+
kind: "im-gateway";
|
|
25
|
+
channel: string;
|
|
26
|
+
target: string;
|
|
27
|
+
/** How this route renders a GatewayReply URL action. */
|
|
28
|
+
replyButton?: "native" | "link";
|
|
29
|
+
/** Host-mediated attachment kinds supported by the originating route. */
|
|
30
|
+
replyAttachmentKinds?: PetReplyAttachmentKind[];
|
|
31
|
+
}
|
|
32
|
+
export type PetReplyAttachmentKind = "image" | "file" | "audio" | "video";
|
|
33
|
+
export type PetLongTaskEventKind = "created" | "started" | "progress" | "waiting" | "paused" | "resumed" | "retrying" | "artifact" | "checkpoint" | "verification-changed" | "interrupted" | "completed" | "failed" | "cancelled" | "closure-decided" | "continuation-started" | "closure-recorded";
|
|
34
|
+
export interface PetLongTaskEvent {
|
|
35
|
+
id: string;
|
|
36
|
+
sequence: number;
|
|
37
|
+
kind: PetLongTaskEventKind;
|
|
38
|
+
at: number;
|
|
39
|
+
message?: string;
|
|
40
|
+
phase?: PetLongTaskPhase;
|
|
41
|
+
waitingFor?: string;
|
|
42
|
+
nextAction?: string;
|
|
43
|
+
artifacts?: PetLongTaskArtifact[];
|
|
44
|
+
}
|
|
45
|
+
export interface PetLongTask {
|
|
46
|
+
schemaVersion: typeof PET_LONG_TASK_SCHEMA_VERSION;
|
|
47
|
+
id: string;
|
|
48
|
+
originClientMessageId: string;
|
|
49
|
+
objective: string;
|
|
50
|
+
workspacePath: string | null;
|
|
51
|
+
sessionId: string;
|
|
52
|
+
/** Explicit external execution backend, when the user required one. */
|
|
53
|
+
executionBackend?: PetWorkExecutionBackend;
|
|
54
|
+
/** Ordinary final response, or persistent Goal verdict, required for closure. */
|
|
55
|
+
verificationMode: PetLongTaskVerificationMode;
|
|
56
|
+
completionTarget?: PetLongTaskCompletionTarget;
|
|
57
|
+
/** Number of terminal-result decisions Mimi has autonomously continued. */
|
|
58
|
+
continuationDepth?: number;
|
|
59
|
+
status: PetLongTaskStatus;
|
|
60
|
+
phase: PetLongTaskPhase;
|
|
61
|
+
attempt: number;
|
|
62
|
+
revision: number;
|
|
63
|
+
createdAt: number;
|
|
64
|
+
updatedAt: number;
|
|
65
|
+
startedAt?: number;
|
|
66
|
+
completedAt?: number;
|
|
67
|
+
/** The current attempt's terminal outcome reached durable Pet work memory. */
|
|
68
|
+
closureRecordedAt?: number;
|
|
69
|
+
/** Durable Mimi closure decision, persisted before any continuation side effect. */
|
|
70
|
+
closureDecision?: PetLongTaskClosureDecision;
|
|
71
|
+
/** Latest assistant-authored result/checkpoint, kept separate from UI progress text. */
|
|
72
|
+
resultSummary?: string;
|
|
73
|
+
summary?: string;
|
|
74
|
+
waitingFor?: string;
|
|
75
|
+
nextAction?: string;
|
|
76
|
+
lastError?: string;
|
|
77
|
+
artifacts: PetLongTaskArtifact[];
|
|
78
|
+
events: PetLongTaskEvent[];
|
|
79
|
+
}
|
|
80
|
+
export interface PetLongTaskContinuationDecision {
|
|
81
|
+
clientMessageId: string;
|
|
82
|
+
objective: string;
|
|
83
|
+
workspacePath: string | null;
|
|
84
|
+
executionBackend?: PetWorkExecutionBackend;
|
|
85
|
+
}
|
|
86
|
+
export interface PetLongTaskClosureDecision {
|
|
87
|
+
key: string;
|
|
88
|
+
text: string;
|
|
89
|
+
decidedAt: number;
|
|
90
|
+
/** Explicit GatewayReply attachment intent from Mimi's closure turn. */
|
|
91
|
+
replyAttachmentPaths?: string[];
|
|
92
|
+
/** Optional GatewayReply URL action, persisted for idempotent replay. */
|
|
93
|
+
replyButton?: {
|
|
94
|
+
text: string;
|
|
95
|
+
url: string;
|
|
96
|
+
};
|
|
97
|
+
continuation?: PetLongTaskContinuationDecision;
|
|
98
|
+
launch?: {
|
|
99
|
+
sessionId: string;
|
|
100
|
+
taskId?: string;
|
|
101
|
+
at: number;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export interface PetLongTaskSnapshot {
|
|
105
|
+
revision: number;
|
|
106
|
+
observedAt: number;
|
|
107
|
+
tasks: PetLongTask[];
|
|
108
|
+
}
|
|
109
|
+
export type PetLongTaskControlAction = "pause" | "resume" | "retry" | "cancel";
|
|
110
|
+
export interface PetLongTaskControlRequest {
|
|
111
|
+
taskId: string;
|
|
112
|
+
action: PetLongTaskControlAction;
|
|
113
|
+
}
|
|
114
|
+
export type PetLongTaskControlResult = {
|
|
115
|
+
ok: true;
|
|
116
|
+
task: PetLongTask;
|
|
117
|
+
} | {
|
|
118
|
+
ok: false;
|
|
119
|
+
code: "not-found" | "invalid-state" | "worker-error";
|
|
120
|
+
message: string;
|
|
121
|
+
};
|
|
122
|
+
export interface CreatePetLongTaskInput {
|
|
123
|
+
id: string;
|
|
124
|
+
originClientMessageId: string;
|
|
125
|
+
objective: string;
|
|
126
|
+
workspacePath: string | null;
|
|
127
|
+
sessionId: string;
|
|
128
|
+
executionBackend?: PetWorkExecutionBackend;
|
|
129
|
+
verificationMode?: PetLongTaskVerificationMode;
|
|
130
|
+
completionTarget?: PetLongTaskCompletionTarget;
|
|
131
|
+
continuationDepth?: number;
|
|
132
|
+
at: number;
|
|
133
|
+
}
|
|
134
|
+
export type PetLongTaskTransition = {
|
|
135
|
+
kind: "started";
|
|
136
|
+
at: number;
|
|
137
|
+
message?: string;
|
|
138
|
+
} | {
|
|
139
|
+
kind: "progress";
|
|
140
|
+
at: number;
|
|
141
|
+
phase: PetLongTaskPhase;
|
|
142
|
+
summary: string;
|
|
143
|
+
} | {
|
|
144
|
+
kind: "waiting";
|
|
145
|
+
at: number;
|
|
146
|
+
waitingFor: string;
|
|
147
|
+
message?: string;
|
|
148
|
+
} | {
|
|
149
|
+
kind: "paused";
|
|
150
|
+
at: number;
|
|
151
|
+
reason?: string;
|
|
152
|
+
} | {
|
|
153
|
+
kind: "resumed";
|
|
154
|
+
at: number;
|
|
155
|
+
message?: string;
|
|
156
|
+
} | {
|
|
157
|
+
kind: "retrying";
|
|
158
|
+
at: number;
|
|
159
|
+
reason?: string;
|
|
160
|
+
} | {
|
|
161
|
+
kind: "artifact";
|
|
162
|
+
at: number;
|
|
163
|
+
artifacts: PetLongTaskArtifact[];
|
|
164
|
+
} | {
|
|
165
|
+
kind: "checkpoint";
|
|
166
|
+
at: number;
|
|
167
|
+
summary: string;
|
|
168
|
+
nextAction?: string;
|
|
169
|
+
artifacts?: PetLongTaskArtifact[];
|
|
170
|
+
} | {
|
|
171
|
+
kind: "verification-changed";
|
|
172
|
+
at: number;
|
|
173
|
+
mode: PetLongTaskVerificationMode;
|
|
174
|
+
} | {
|
|
175
|
+
kind: "interrupted";
|
|
176
|
+
at: number;
|
|
177
|
+
reason: string;
|
|
178
|
+
} | {
|
|
179
|
+
kind: "completed";
|
|
180
|
+
at: number;
|
|
181
|
+
summary?: string;
|
|
182
|
+
artifacts?: PetLongTaskArtifact[];
|
|
183
|
+
} | {
|
|
184
|
+
kind: "failed";
|
|
185
|
+
at: number;
|
|
186
|
+
error: string;
|
|
187
|
+
summary?: string;
|
|
188
|
+
} | {
|
|
189
|
+
kind: "cancelled";
|
|
190
|
+
at: number;
|
|
191
|
+
reason?: string;
|
|
192
|
+
} | {
|
|
193
|
+
kind: "closure-decided";
|
|
194
|
+
at: number;
|
|
195
|
+
key: string;
|
|
196
|
+
text: string;
|
|
197
|
+
replyAttachmentPaths?: string[];
|
|
198
|
+
replyButton?: {
|
|
199
|
+
text: string;
|
|
200
|
+
url: string;
|
|
201
|
+
};
|
|
202
|
+
continuation?: PetLongTaskContinuationDecision;
|
|
203
|
+
} | {
|
|
204
|
+
kind: "continuation-started";
|
|
205
|
+
at: number;
|
|
206
|
+
key: string;
|
|
207
|
+
sessionId: string;
|
|
208
|
+
taskId?: string;
|
|
209
|
+
} | {
|
|
210
|
+
kind: "closure-recorded";
|
|
211
|
+
at: number;
|
|
212
|
+
};
|
|
213
|
+
export declare function createPetLongTask(input: CreatePetLongTaskInput): PetLongTask;
|
|
214
|
+
/**
|
|
215
|
+
* Apply one durable transition. Terminal tasks only accept retry/cancel or a
|
|
216
|
+
* closure-delivery acknowledgement; late
|
|
217
|
+
* worker events are ignored so a stale completion cannot undo an explicit user
|
|
218
|
+
* action such as pause or cancel.
|
|
219
|
+
*/
|
|
220
|
+
export declare function transitionPetLongTask(current: PetLongTask, transition: PetLongTaskTransition): PetLongTask;
|
|
221
|
+
/** Defensive parser used by durable hosts. Invalid rows are dropped independently. */
|
|
222
|
+
export declare function parsePetLongTask(value: unknown): PetLongTask | null;
|
|
223
|
+
export interface PetLongTaskContext {
|
|
224
|
+
version: 1;
|
|
225
|
+
active: Array<{
|
|
226
|
+
taskId: string;
|
|
227
|
+
objective: string;
|
|
228
|
+
status: PetLongTaskStatus;
|
|
229
|
+
phase: PetLongTaskPhase;
|
|
230
|
+
sessionId: string;
|
|
231
|
+
workspace?: string;
|
|
232
|
+
attempt: number;
|
|
233
|
+
updatedAt: number;
|
|
234
|
+
summary?: string;
|
|
235
|
+
waitingFor?: string;
|
|
236
|
+
nextAction?: string;
|
|
237
|
+
}>;
|
|
238
|
+
recent: Array<{
|
|
239
|
+
taskId: string;
|
|
240
|
+
objective: string;
|
|
241
|
+
status: "completed" | "failed" | "cancelled";
|
|
242
|
+
sessionId: string;
|
|
243
|
+
workspace?: string;
|
|
244
|
+
updatedAt: number;
|
|
245
|
+
summary?: string;
|
|
246
|
+
artifacts?: PetLongTaskArtifact[];
|
|
247
|
+
}>;
|
|
248
|
+
}
|
|
249
|
+
/** Bounded task continuity injected into each Mimi manager turn. */
|
|
250
|
+
export declare function buildPetLongTaskContext(tasks: readonly PetLongTask[]): PetLongTaskContext;
|
|
251
|
+
export declare function petLongTaskResumePrompt(task: PetLongTask): string;
|