stitchkit 0.70.1 → 0.70.2

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 (48) hide show
  1. package/dist/agent-runtime/harness-control.d.ts +2 -0
  2. package/dist/agent-runtime/harness-control.d.ts.map +1 -1
  3. package/dist/agent-runtime/history-chronology.d.ts +19 -0
  4. package/dist/agent-runtime/history-chronology.d.ts.map +1 -0
  5. package/dist/agent-runtime/history.d.ts.map +1 -1
  6. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  7. package/dist/agent-runtime/terminal-status.d.ts.map +1 -1
  8. package/dist/agent-runtime-browser.js +51 -51
  9. package/dist/agent-runtime-coding-tools.js +2 -2
  10. package/dist/agent-runtime-harness.js +60 -16
  11. package/dist/agent-runtime-openrouter.js +2 -2
  12. package/dist/agent-runtime-sqlite-bun.js +5 -5
  13. package/dist/agent-runtime-sqlite-node.js +5 -5
  14. package/dist/agent-runtime.js +110 -110
  15. package/dist/application-grammy.js +2 -2
  16. package/dist/application.js +63 -63
  17. package/dist/browser/live-state.d.ts +126 -0
  18. package/dist/browser/live-state.d.ts.map +1 -0
  19. package/dist/cli.js +5 -5
  20. package/dist/contract/index.js +20 -20
  21. package/dist/declaration.d.ts +4 -0
  22. package/dist/declaration.d.ts.map +1 -1
  23. package/dist/declaration.js +22 -22
  24. package/dist/files.js +3 -3
  25. package/dist/{index-vy5bjy07.js → index-4qfqy0m6.js} +21 -31
  26. package/dist/{index-10gbbbaa.js → index-9sx8tbz2.js} +1 -1
  27. package/dist/{index-4g196jmf.js → index-a01jky8m.js} +69 -7
  28. package/dist/{index-hsabxjz0.js → index-jw81xr75.js} +1 -1
  29. package/dist/index-y2s6h5bf.js +83 -0
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +667 -56
  33. package/dist/node.js +26 -26
  34. package/dist/observability/index.js +22 -22
  35. package/dist/react.js +2 -2
  36. package/dist/realtime/contract.d.ts +30 -11
  37. package/dist/realtime/contract.d.ts.map +1 -1
  38. package/dist/realtime/index.d.ts +1 -1
  39. package/dist/realtime/index.d.ts.map +1 -1
  40. package/dist/server/index.js +79 -79
  41. package/dist/server/multipart.d.ts.map +1 -1
  42. package/dist/testing/surface-conformance.d.ts +4 -2
  43. package/dist/testing/surface-conformance.d.ts.map +1 -1
  44. package/dist/testing.js +122 -111
  45. package/dist/tools.js +57 -57
  46. package/llms-full.txt +224 -4
  47. package/package.json +1 -1
  48. package/dist/index-es0h4w26.js +0 -63
@@ -1065,68 +1065,68 @@ function managedServerResource(config) {
1065
1065
  });
1066
1066
  }
1067
1067
  export {
1068
- ActivityIdSchema,
1069
- ActivityLiveStateSchema,
1070
- ActivitySnapshotSchema,
1071
- ActivityStageIdSchema,
1072
- ActivityStageSnapshotSchema,
1073
- ActivityTokenBrand,
1074
- ApplicationAdmissionError,
1075
- ApplicationAdmissionSnapshotSchema,
1076
- ApplicationHealthHandlerOptionsSchema,
1077
- ApplicationHealthSchema,
1078
- ApplicationIdSchema,
1079
- ApplicationLifecycleEventSchema,
1080
- ApplicationLifecycleSchema,
1081
- ApplicationOperationalHandlersOptionsSchema,
1082
- ApplicationResourceShutdownSchema,
1083
- ApplicationShutdownBudgetSchema,
1084
- ApplicationShutdownOptionsSchema,
1085
- ApplicationShutdownResultSchema,
1086
- ApplicationSnapshotSchema,
1087
- ApplicationSnapshotSinkStatusSchema,
1088
- ApplicationStatusProjectionSchema,
1089
- BoundedAdmissionPolicySchema,
1090
- BoundedAdmissionRefusalError,
1091
- BoundedAdmissionRefusalReasonSchema,
1092
- BoundedAdmissionSnapshotSchema,
1093
- BoundedAdmissionStateSchema,
1094
- BoundedChannelPolicySchema,
1095
- BoundedChannelReaderError,
1096
- BoundedChannelSnapshotSchema,
1097
- BoundedChannelStateSchema,
1098
- BoundedOperationWaitError,
1099
- BoundedRateBudgetSchema,
1100
- CreditWindowSnapshotSchema,
1101
- DiagnosticJournalCloseResultSchema,
1102
- DiagnosticJournalFailurePhaseSchema,
1103
- DiagnosticJournalFrameSchema,
1104
- DiagnosticJournalLimitsSchema,
1105
- DiagnosticJournalRefusalReasonSchema,
1106
- DiagnosticJournalStateSchema,
1107
- DiagnosticJournalStatusSchema,
1108
- DiagnosticJournalSubmitResultSchema,
1109
- DiagnosticJournalWaitResultSchema,
1110
- ManagedResourceSnapshotSchema,
1111
- ManagedResourceStateSchema,
1112
- ManagedScheduleDescriptorSchema,
1113
- ManagedScheduleErrorPolicySchema,
1114
- ManagedScheduleOverlapSchema,
1115
- ManagedScheduleStatusSchema,
1116
- applicationLifecycleEvent,
1117
- createActivityProjection,
1118
- createApplication,
1119
- createApplicationEventSink,
1120
- createApplicationHealthHandler,
1121
- createApplicationOperationalHandlers,
1122
- createApplicationSnapshotSink,
1123
- createBoundedAdmission,
1124
- createBoundedChannel,
1125
- createCreditWindow,
1126
- createDiagnosticJournal,
1127
- createManagedSchedule,
1128
- defineManagedResource,
1129
- managedResourceDependencyId,
1068
+ projectApplicationStatus,
1130
1069
  managedServerResource,
1131
- projectApplicationStatus
1070
+ managedResourceDependencyId,
1071
+ defineManagedResource,
1072
+ createManagedSchedule,
1073
+ createDiagnosticJournal,
1074
+ createCreditWindow,
1075
+ createBoundedChannel,
1076
+ createBoundedAdmission,
1077
+ createApplicationSnapshotSink,
1078
+ createApplicationOperationalHandlers,
1079
+ createApplicationHealthHandler,
1080
+ createApplicationEventSink,
1081
+ createApplication,
1082
+ createActivityProjection,
1083
+ applicationLifecycleEvent,
1084
+ ManagedScheduleStatusSchema,
1085
+ ManagedScheduleOverlapSchema,
1086
+ ManagedScheduleErrorPolicySchema,
1087
+ ManagedScheduleDescriptorSchema,
1088
+ ManagedResourceStateSchema,
1089
+ ManagedResourceSnapshotSchema,
1090
+ DiagnosticJournalWaitResultSchema,
1091
+ DiagnosticJournalSubmitResultSchema,
1092
+ DiagnosticJournalStatusSchema,
1093
+ DiagnosticJournalStateSchema,
1094
+ DiagnosticJournalRefusalReasonSchema,
1095
+ DiagnosticJournalLimitsSchema,
1096
+ DiagnosticJournalFrameSchema,
1097
+ DiagnosticJournalFailurePhaseSchema,
1098
+ DiagnosticJournalCloseResultSchema,
1099
+ CreditWindowSnapshotSchema,
1100
+ BoundedRateBudgetSchema,
1101
+ BoundedOperationWaitError,
1102
+ BoundedChannelStateSchema,
1103
+ BoundedChannelSnapshotSchema,
1104
+ BoundedChannelReaderError,
1105
+ BoundedChannelPolicySchema,
1106
+ BoundedAdmissionStateSchema,
1107
+ BoundedAdmissionSnapshotSchema,
1108
+ BoundedAdmissionRefusalReasonSchema,
1109
+ BoundedAdmissionRefusalError,
1110
+ BoundedAdmissionPolicySchema,
1111
+ ApplicationStatusProjectionSchema,
1112
+ ApplicationSnapshotSinkStatusSchema,
1113
+ ApplicationSnapshotSchema,
1114
+ ApplicationShutdownResultSchema,
1115
+ ApplicationShutdownOptionsSchema,
1116
+ ApplicationShutdownBudgetSchema,
1117
+ ApplicationResourceShutdownSchema,
1118
+ ApplicationOperationalHandlersOptionsSchema,
1119
+ ApplicationLifecycleSchema,
1120
+ ApplicationLifecycleEventSchema,
1121
+ ApplicationIdSchema,
1122
+ ApplicationHealthSchema,
1123
+ ApplicationHealthHandlerOptionsSchema,
1124
+ ApplicationAdmissionSnapshotSchema,
1125
+ ApplicationAdmissionError,
1126
+ ActivityTokenBrand,
1127
+ ActivityStageSnapshotSchema,
1128
+ ActivityStageIdSchema,
1129
+ ActivitySnapshotSchema,
1130
+ ActivityLiveStateSchema,
1131
+ ActivityIdSchema
1132
1132
  };
@@ -0,0 +1,126 @@
1
+ import { z } from 'zod';
2
+ export declare const LiveStatePhaseSchema: z.ZodEnum<{
3
+ closed: "closed";
4
+ idle: "idle";
5
+ live: "live";
6
+ opening: "opening";
7
+ "resync-required": "resync-required";
8
+ unavailable: "unavailable";
9
+ }>;
10
+ export type LiveStatePhase = z.infer<typeof LiveStatePhaseSchema>;
11
+ export declare const LiveStateStopReasonSchema: z.ZodEnum<{
12
+ "buffer-overflow": "buffer-overflow";
13
+ "controller-capacity": "controller-capacity";
14
+ "controller-error": "controller-error";
15
+ gap: "gap";
16
+ "source-error": "source-error";
17
+ "source-unavailable": "source-unavailable";
18
+ }>;
19
+ export type LiveStateStopReason = z.infer<typeof LiveStateStopReasonSchema>;
20
+ export declare const LiveStateControllerStatusSchema: z.ZodReadonly<z.ZodObject<{
21
+ phase: z.ZodEnum<{
22
+ closed: "closed";
23
+ idle: "idle";
24
+ live: "live";
25
+ opening: "opening";
26
+ "resync-required": "resync-required";
27
+ unavailable: "unavailable";
28
+ }>;
29
+ generation: z.ZodNumber;
30
+ hasValue: z.ZodBoolean;
31
+ bufferedEvents: z.ZodNumber;
32
+ bufferedBytes: z.ZodNumber;
33
+ receivedEvents: z.ZodNumber;
34
+ appliedEvents: z.ZodNumber;
35
+ duplicateEvents: z.ZodNumber;
36
+ gapEvents: z.ZodNumber;
37
+ refusedEvents: z.ZodNumber;
38
+ reason: z.ZodOptional<z.ZodEnum<{
39
+ "buffer-overflow": "buffer-overflow";
40
+ "controller-capacity": "controller-capacity";
41
+ "controller-error": "controller-error";
42
+ gap: "gap";
43
+ "source-error": "source-error";
44
+ "source-unavailable": "source-unavailable";
45
+ }>>;
46
+ }, z.core.$strict>>;
47
+ export type LiveStateControllerStatus = z.infer<typeof LiveStateControllerStatusSchema>;
48
+ export interface LiveStateControllerSnapshot<TState> extends LiveStateControllerStatus {
49
+ readonly value?: TState;
50
+ }
51
+ export type LiveStateEventDecision<TState> = {
52
+ readonly outcome: 'applied';
53
+ readonly state: TState;
54
+ } | {
55
+ readonly outcome: 'duplicate';
56
+ } | {
57
+ readonly outcome: 'gap';
58
+ };
59
+ export interface LiveStateSourceOpenInput<TEvent> {
60
+ readonly signal: AbortSignal;
61
+ /** May run before `open()` resolves; the controller buffers those events finitely. */
62
+ readonly onEvent: (event: TEvent) => void;
63
+ /** Reports loss of this source generation. Reconnect policy remains source-owned. */
64
+ readonly onUnavailable: () => void;
65
+ }
66
+ export interface LiveStateSourceOpenResult<TState> {
67
+ /** State at the source's declared consistency point. */
68
+ readonly snapshot: TState;
69
+ /**
70
+ * Releases only resources owned by this opened source generation. Must be
71
+ * idempotent because abort-aware sources may already have begun cleanup.
72
+ */
73
+ close(): void | Promise<void>;
74
+ }
75
+ export interface LiveStateSource<TState, TEvent> {
76
+ /**
77
+ * Open one continuous generation.
78
+ *
79
+ * By resolution, every event after `snapshot`'s consistency point has already
80
+ * been or will be passed to `onEvent`. A source that performs an unrelated
81
+ * snapshot read followed by subscription does not satisfy this contract.
82
+ */
83
+ open(input: LiveStateSourceOpenInput<TEvent>): Promise<LiveStateSourceOpenResult<TState>>;
84
+ }
85
+ export interface LiveStateControllerError {
86
+ readonly error: unknown;
87
+ readonly generation: number;
88
+ readonly phase: LiveStatePhase;
89
+ }
90
+ export interface LiveStateSubscriberError<TState> {
91
+ readonly error: unknown;
92
+ readonly snapshot: LiveStateControllerSnapshot<TState>;
93
+ }
94
+ export interface LiveStateControllerConfig<TState, TEvent> {
95
+ readonly source: LiveStateSource<TState, TEvent>;
96
+ /** Provider-owned cursor/revision policy and state reduction. Must be synchronous. */
97
+ readonly applyEvent: (state: TState, event: TEvent) => LiveStateEventDecision<TState>;
98
+ readonly maxBufferedEvents: number;
99
+ readonly maxBufferedBytes: number;
100
+ /** Exact retained-byte accounting for an event waiting behind the snapshot boundary. */
101
+ readonly sizeOfEvent: (event: TEvent) => number;
102
+ readonly signal?: AbortSignal;
103
+ onControllerError?(failure: LiveStateControllerError): void;
104
+ onSubscriberError?(failure: LiveStateSubscriberError<TState>): void;
105
+ }
106
+ export interface LiveStateController<TState> {
107
+ /** Opens only from `idle`; use `resync()` after loss or an explicit refresh. */
108
+ start(): Promise<LiveStateControllerSnapshot<TState>>;
109
+ /**
110
+ * Fences the current generation and opens a fresh source boundary while
111
+ * bounded pending-operation capacity permits. Otherwise it returns
112
+ * `unavailable/controller-capacity`; retry after `resync-required` is published.
113
+ */
114
+ resync(): Promise<LiveStateControllerSnapshot<TState>>;
115
+ getSnapshot(): LiveStateControllerSnapshot<TState>;
116
+ /** Synchronous external-store subscription; async listeners are removed as invalid. */
117
+ subscribe(listener: (snapshot: LiveStateControllerSnapshot<TState>) => void): () => void;
118
+ /** Fences current work and closes any source handle that has already opened. */
119
+ close(): Promise<LiveStateControllerSnapshot<TState>>;
120
+ }
121
+ /**
122
+ * Keep one application state current across a provider-declared snapshot/event
123
+ * boundary without owning transport reconnect, schemas, replay storage or cursors.
124
+ */
125
+ export declare function createLiveStateController<TState, TEvent>(config: LiveStateControllerConfig<TState, TEvent>): LiveStateController<TState>;
126
+ //# sourceMappingURL=live-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-state.d.ts","sourceRoot":"","sources":["../../src/browser/live-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,oBAAoB;;;;;;;EAO/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,yBAAyB;;;;;;;EAOpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;mBAe/B,CAAC;AACd,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,MAAM,WAAW,2BAA2B,CAAC,MAAM,CAAE,SAAQ,yBAAyB;IACpF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,sBAAsB,CAAC,MAAM,IACrC;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvD;IAAE,QA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AAE,MAAM,KAAK,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACtF,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,wFAAwF;IACxF,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,iBAAiB,CAAC,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC5D,iBAAiB,CAAC,CAAC,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CACrE;AAED,MAAM,WAAW,mBAAmB,CAAC,MAAM;IACzC,gFAAgF;IAChF,KAAK,IAAI,OAAO,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;IACtD;;;;OAIG;IACH,MAAM,IAAI,OAAO,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,WAAW,IAAI,2BAA2B,CAAC,MAAM,CAAC,CAAC;IACnD,uFAAuF;IACvF,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,2BAA2B,CAAC,MAAM,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACzF,gFAAgF;IAChF,KAAK,IAAI,OAAO,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;CACvD;AAmBD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EACtD,MAAM,EAAE,yBAAyB,CAAC,MAAM,EAAE,MAAM,CAAC,GAChD,mBAAmB,CAAC,MAAM,CAAC,CAsZ7B"}
package/dist/cli.js CHANGED
@@ -20,10 +20,10 @@ import"./index-0w9abg87.js";
20
20
  import"./index-qyrqwr4c.js";
21
21
  import"./index-6k1937bx.js";
22
22
  export {
23
- DEFAULT_EXIT_CODES,
24
- createCli,
25
- defineCliCommand,
26
- emitResult,
23
+ pollUntilDone,
27
24
  parseCliArgs,
28
- pollUntilDone
25
+ emitResult,
26
+ defineCliCommand,
27
+ createCli,
28
+ DEFAULT_EXIT_CODES
29
29
  };
@@ -23,25 +23,25 @@ import {
23
23
  } from "../index-f6n5n7nz.js";
24
24
  import"../index-ksp6e2ye.js";
25
25
  export {
26
- ALL_TRANSPORTS,
27
- AppError,
28
- ContractStreamFrameSchema,
29
- DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
30
- ManagedFilePathSchema,
31
- ManagedFileRefSchema,
32
- STITCH_ERROR_STATUS,
33
- appError,
34
- badRequest,
35
- conflict,
36
- createContractFactory,
37
- decodeCursor,
38
- defineContract,
39
- defineErrors,
40
- encodeCursor,
41
- forbidden,
42
- isStitchErrorCode,
43
- notFound,
44
- paginatedSchema,
26
+ unauthorized,
45
27
  rateLimited,
46
- unauthorized
28
+ paginatedSchema,
29
+ notFound,
30
+ isStitchErrorCode,
31
+ forbidden,
32
+ encodeCursor,
33
+ defineErrors,
34
+ defineContract,
35
+ decodeCursor,
36
+ createContractFactory,
37
+ conflict,
38
+ badRequest,
39
+ appError,
40
+ STITCH_ERROR_STATUS,
41
+ ManagedFileRefSchema,
42
+ ManagedFilePathSchema,
43
+ DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
44
+ ContractStreamFrameSchema,
45
+ AppError,
46
+ ALL_TRANSPORTS
47
47
  };
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * The project declaration — the one machine-readable statement a repository
3
3
  * chooses to make about itself.
4
+ * Identity names its buildable source/artifact, not product membership, a
5
+ * checkout or a harness workspace. Explicit product↔repository membership is
6
+ * many-to-many and belongs to an external registry with its own access policy;
7
+ * dependencies do not create membership or require private companion metadata.
4
8
  *
5
9
  * The schema lives in the published framework, not in the repository that fills
6
10
  * it in, because it has readers that must never disagree: the project itself,
@@ -1 +1 @@
1
- {"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../src/declaration.ts"],"names":[],"mappings":"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;;;;;;kBAEtB,CAAC;AAEZ,0EAA0E;AAC1E,eAAO,MAAM,qBAAqB;;;;;;EAA0D,CAAC;AAE7F;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;kBAclC,CAAC;AAEJ,6EAA6E;AAC7E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0DjC,CAAC;AAyCL,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAKpE;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,GAAG,kBAAkB,CAU3E;AAED,+CAA+C;AAC/C,wBAAgB,eAAe,CAC7B,WAAW,EAAE,kBAAkB,EAC/B,IAAI,EAAE,MAAM,GACX,WAAW,GAAG,SAAS,CAEzB"}
@@ -157,27 +157,27 @@ function findProjectRole(declaration, name) {
157
157
  return declaration.roles.find((role) => role.name === name);
158
158
  }
159
159
  export {
160
- BindingVariableSchema,
161
- PROJECT_DECLARATION_SCHEMA_VERSION,
162
- ProjectBuildInputSchema,
163
- ProjectBuildSchema,
164
- ProjectCommandSchema,
165
- ProjectDeclarationSchema,
166
- ProjectDescriptionSchema,
167
- ProjectEnvShapeSchema,
168
- ProjectEnvVariableSchema,
169
- ProjectIdentitySchema,
170
- ProjectListenerSchema,
171
- ProjectMigrationsSchema,
172
- ProjectReleaseSchema,
173
- ProjectRequirementPhaseSchema,
174
- ProjectRequirementSchema,
175
- ProjectRoleCommandSchema,
176
- ProjectRoleSchema,
177
- ProjectRunModeSchema,
178
- ProjectSlugSchema,
179
- RepositoryPathSchema,
180
- findProjectRole,
160
+ parseProjectDeclaration,
181
161
  namesAMachine,
182
- parseProjectDeclaration
162
+ findProjectRole,
163
+ RepositoryPathSchema,
164
+ ProjectSlugSchema,
165
+ ProjectRunModeSchema,
166
+ ProjectRoleSchema,
167
+ ProjectRoleCommandSchema,
168
+ ProjectRequirementSchema,
169
+ ProjectRequirementPhaseSchema,
170
+ ProjectReleaseSchema,
171
+ ProjectMigrationsSchema,
172
+ ProjectListenerSchema,
173
+ ProjectIdentitySchema,
174
+ ProjectEnvVariableSchema,
175
+ ProjectEnvShapeSchema,
176
+ ProjectDescriptionSchema,
177
+ ProjectDeclarationSchema,
178
+ ProjectCommandSchema,
179
+ ProjectBuildSchema,
180
+ ProjectBuildInputSchema,
181
+ PROJECT_DECLARATION_SCHEMA_VERSION,
182
+ BindingVariableSchema
183
183
  };
package/dist/files.js CHANGED
@@ -8,8 +8,8 @@ import {
8
8
  ManagedFileRefSchema
9
9
  } from "./index-6k1937bx.js";
10
10
  export {
11
- ManagedFileError,
12
- ManagedFilePathSchema,
11
+ createManagedFileBoundary,
13
12
  ManagedFileRefSchema,
14
- createManagedFileBoundary
13
+ ManagedFilePathSchema,
14
+ ManagedFileError
15
15
  };
@@ -1,8 +1,11 @@
1
1
  import {
2
+ advanceToolChronology,
2
3
  assistantStatus,
4
+ canProjectToolChronology,
5
+ createToolChronology,
3
6
  isAssistantHistoryEvidence,
4
7
  isCompleteAgentHistoryTurn
5
- } from "./index-es0h4w26.js";
8
+ } from "./index-y2s6h5bf.js";
6
9
  import {
7
10
  createBoundedSinkManager
8
11
  } from "./index-a59da114.js";
@@ -511,42 +514,20 @@ function interruptedSystemNote(message) {
511
514
  rendered.add("control");
512
515
  return { text: `[interrupted] partial response: ${text}`, rendered };
513
516
  }
514
- function completeToolChronology(message) {
515
- const pending = new Set;
516
- const completed = new Set;
517
- let resultsStarted = false;
518
- for (const part of message.parts) {
519
- if (part.type === "tool-call") {
520
- if (resultsStarted && pending.size > 0)
521
- return false;
522
- if (pending.size === 0)
523
- resultsStarted = false;
524
- if (pending.has(part.callId) || completed.has(part.callId))
525
- return false;
526
- pending.add(part.callId);
527
- }
528
- if (part.type === "tool-result") {
529
- if (!pending.delete(part.callId))
530
- return false;
531
- completed.add(part.callId);
532
- resultsStarted = true;
533
- }
534
- if (part.type === "tool-approval-request") {
535
- if (!pending.delete(part.callId))
536
- return false;
537
- completed.add(part.callId);
538
- resultsStarted = true;
539
- }
540
- }
541
- return pending.size === 0;
542
- }
543
517
  async function projectAgentHistoryDetailed(messages, options = {}) {
544
518
  const projected = [];
545
519
  const system = [];
546
520
  const decisions = [];
547
521
  const interruptedRule = options.interruptedAssistant ?? "assistant-marked";
548
522
  let observedUser = false;
523
+ let chronology = createToolChronology();
524
+ let conversationId;
549
525
  for (const message of messages) {
526
+ if (message.conversationId !== conversationId) {
527
+ conversationId = message.conversationId;
528
+ chronology = createToolChronology();
529
+ observedUser = false;
530
+ }
550
531
  if (message.role === "assistant" && !isAssistantHistoryEvidence(message.status, options.evidencePolicy)) {
551
532
  decisions.push(decide(message, "omitted", message.status === "superseded" ? "superseded" : "draft-or-failed"));
552
533
  continue;
@@ -557,6 +538,8 @@ async function projectAgentHistoryDetailed(messages, options = {}) {
557
538
  }
558
539
  if (message.role === "user") {
559
540
  const user = await userMessage(message, options);
541
+ if (chronology.pending === 0)
542
+ chronology = createToolChronology();
560
543
  observedUser = true;
561
544
  if (user.message) {
562
545
  projected.push(user.message);
@@ -598,7 +581,8 @@ async function projectAgentHistoryDetailed(messages, options = {}) {
598
581
  }
599
582
  continue;
600
583
  }
601
- if (!completeToolChronology(message)) {
584
+ const nextChronology = advanceToolChronology(chronology, message.parts);
585
+ if (!nextChronology || !canProjectToolChronology(nextChronology)) {
602
586
  if (options.incompleteToolTurn === "error") {
603
587
  throw new Error(`Assistant message ${message.id} has incomplete tool chronology`);
604
588
  }
@@ -606,6 +590,7 @@ async function projectAgentHistoryDetailed(messages, options = {}) {
606
590
  continue;
607
591
  }
608
592
  const assistant = assistantMessages(message, interrupted ? "interrupted" : message.status === "failed" ? "failed" : undefined);
593
+ chronology = nextChronology;
609
594
  projected.push(...assistant.messages);
610
595
  decisions.push(assistant.messages.length > 0 ? decide(message, "projected", "projected", assistant.rendered) : decide(message, "omitted", "empty"));
611
596
  }
@@ -1477,6 +1462,11 @@ function createRunExecutor(dependencies) {
1477
1462
  evidencePolicy: config.history.evidencePolicy
1478
1463
  }
1479
1464
  });
1465
+ for (const decision of detailed.decisions) {
1466
+ if (decision.action === "omitted" && run.inputMessageIds.includes(decision.messageId) && source.messages.some((message) => message.id === decision.messageId && message.role === "tool")) {
1467
+ throw new Error(`Invalid approval continuation ${decision.messageId}: ${decision.reason}`);
1468
+ }
1469
+ }
1480
1470
  carriedSystem = detailed.system;
1481
1471
  return [...detailed.messages];
1482
1472
  };
@@ -8,7 +8,7 @@ import {
8
8
  AgentRuntimeHeadSchema,
9
9
  AgentStoredRunSchema,
10
10
  createAgentRuntimeStore
11
- } from "./index-hsabxjz0.js";
11
+ } from "./index-jw81xr75.js";
12
12
  import {
13
13
  AgentMessageSchema,
14
14
  AgentRunSchema
@@ -54,7 +54,20 @@ var DEFAULT_MAX_PARTS = 1000;
54
54
  var CRLF = new Uint8Array([13, 10]);
55
55
  var HEADER_END = new Uint8Array([13, 10, 13, 10]);
56
56
  var decoder = new TextDecoder;
57
+ var headerDecoder = new TextDecoder("utf-8", { fatal: true });
57
58
  var encoder = new TextEncoder;
59
+ var TOKEN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
60
+ function hasControl(value, allowTab = false) {
61
+ for (let index = 0;index < value.length; index++) {
62
+ const code = value.charCodeAt(index);
63
+ if (code < 32 && !(allowTab && code === 9) || code === 127)
64
+ return true;
65
+ }
66
+ return false;
67
+ }
68
+ function trimWhitespace(value) {
69
+ return value.replace(/^[ \t]+|[ \t]+$/g, "");
70
+ }
58
71
  function indexOfBytes(haystack, needle) {
59
72
  outer:
60
73
  for (let index = 0;index <= haystack.length - needle.length; index += 1) {
@@ -97,10 +110,49 @@ function parseBoundary(req) {
97
110
  return boundary;
98
111
  }
99
112
  function parseDisposition(value) {
100
- if (!value || !/^form-data(?:;|$)/i.test(value))
113
+ if (!value)
114
+ badRequest("Invalid multipart disposition");
115
+ const separator = value.indexOf(";");
116
+ const kind = separator < 0 ? value : value.slice(0, separator);
117
+ if (trimWhitespace(kind).toLowerCase() !== "form-data") {
101
118
  badRequest("Invalid multipart disposition");
102
- const name = /(?:^|;)\s*name="([^"]*)"/i.exec(value)?.[1];
103
- const filename = /(?:^|;)\s*filename="([^"]*)"/i.exec(value)?.[1];
119
+ }
120
+ const parameters = new Map;
121
+ let rest = separator < 0 ? "" : value.slice(separator);
122
+ while (rest.length > 0) {
123
+ const match = /^;[ \t]*([^=; \t]+)[ \t]*=[ \t]*(?:"((?:[^"\\]|\\.)*)"|([^; \t]+))[ \t]*/.exec(rest);
124
+ if (!match?.[1])
125
+ badRequest("Invalid multipart disposition parameter");
126
+ const key = match[1].toLowerCase();
127
+ if (!TOKEN.test(key) || parameters.has(key)) {
128
+ badRequest("Invalid or duplicate multipart disposition parameter");
129
+ }
130
+ const quoted = match[2];
131
+ const raw = match[3] ?? "";
132
+ if (quoted === undefined && !TOKEN.test(raw)) {
133
+ badRequest("Invalid multipart disposition parameter");
134
+ }
135
+ const decoded = quoted === undefined ? raw : quoted.replace(/\\(.)/g, "$1");
136
+ if (hasControl(decoded))
137
+ badRequest("Invalid multipart disposition parameter");
138
+ parameters.set(key, decoded);
139
+ rest = rest.slice(match[0].length);
140
+ }
141
+ const name = parameters.get("name");
142
+ let filename = parameters.get("filename");
143
+ const extended = parameters.get("filename*");
144
+ if (extended !== undefined) {
145
+ const match = /^utf-8'[A-Za-z0-9-]*'((?:[!#$&+.^_`|~0-9A-Za-z-]|%[0-9A-Fa-f]{2})*)$/i.exec(extended);
146
+ if (!match)
147
+ badRequest("Invalid multipart extended filename");
148
+ try {
149
+ filename = decodeURIComponent(match[1] ?? "");
150
+ } catch {
151
+ badRequest("Invalid multipart extended filename");
152
+ }
153
+ if (hasControl(filename))
154
+ badRequest("Invalid multipart extended filename");
155
+ }
104
156
  if (!name || isUnsafeKey(name))
105
157
  badRequest("Invalid multipart field name");
106
158
  return filename === undefined ? { name } : { name, filename };
@@ -108,23 +160,33 @@ function parseDisposition(value) {
108
160
  function parsePartHeaders(bytes) {
109
161
  let text;
110
162
  try {
111
- text = decoder.decode(bytes);
163
+ text = headerDecoder.decode(bytes);
112
164
  } catch {
113
165
  badRequest("Invalid multipart headers");
114
166
  }
115
- const headers = new Headers;
167
+ const headers = new Map;
116
168
  for (const line of text.split(`\r
117
169
  `)) {
118
170
  const separator = line.indexOf(":");
119
171
  if (separator <= 0)
120
172
  badRequest("Invalid multipart header");
121
- headers.append(line.slice(0, separator).trim(), line.slice(separator + 1).trim());
173
+ const name = line.slice(0, separator).toLowerCase();
174
+ const value = trimWhitespace(line.slice(separator + 1));
175
+ if (!TOKEN.test(name) || hasControl(value, true)) {
176
+ badRequest("Invalid multipart header");
177
+ }
178
+ if (headers.has(name))
179
+ badRequest("Duplicate multipart header");
180
+ headers.set(name, value);
122
181
  }
123
182
  const disposition = parseDisposition(headers.get("content-disposition") ?? undefined);
124
183
  const rawContentType = headers.get("content-type");
125
184
  const contentType = rawContentType?.split(";", 1)[0]?.trim().toLowerCase();
126
185
  const rawSize = headers.get("content-length");
127
- const declaredSize = rawSize === null ? undefined : Number(rawSize);
186
+ if (rawSize !== undefined && !/^[0-9]+$/.test(rawSize)) {
187
+ badRequest("Invalid multipart part content-length");
188
+ }
189
+ const declaredSize = rawSize === undefined ? undefined : Number(rawSize);
128
190
  if (declaredSize !== undefined && (!Number.isSafeInteger(declaredSize) || declaredSize < 0)) {
129
191
  badRequest("Invalid multipart part content-length");
130
192
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assistantStatus
3
- } from "./index-es0h4w26.js";
3
+ } from "./index-y2s6h5bf.js";
4
4
  import {
5
5
  AgentMessageSchema,
6
6
  AgentRecordIdSchema,