stitchkit 0.70.1 → 0.70.3
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/agent-runtime/harness-control.d.ts +2 -0
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/history-chronology.d.ts +19 -0
- package/dist/agent-runtime/history-chronology.d.ts.map +1 -0
- package/dist/agent-runtime/history.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-status.d.ts.map +1 -1
- package/dist/agent-runtime-browser.js +51 -51
- package/dist/agent-runtime-coding-tools.js +2 -2
- package/dist/agent-runtime-harness.js +60 -16
- package/dist/agent-runtime-openrouter.js +2 -2
- package/dist/agent-runtime-sqlite-bun.js +5 -5
- package/dist/agent-runtime-sqlite-node.js +5 -5
- package/dist/agent-runtime.js +110 -110
- package/dist/application-grammy.js +2 -2
- package/dist/application.js +63 -63
- package/dist/browser/live-state.d.ts +126 -0
- package/dist/browser/live-state.d.ts.map +1 -0
- package/dist/cli.js +5 -5
- package/dist/contract/index.js +20 -20
- package/dist/declaration.d.ts +4 -0
- package/dist/declaration.d.ts.map +1 -1
- package/dist/declaration.js +22 -22
- package/dist/files.js +3 -3
- package/dist/{index-4g196jmf.js → index-1zxf9x2z.js} +112 -20
- package/dist/{index-vy5bjy07.js → index-4qfqy0m6.js} +21 -31
- package/dist/{index-10gbbbaa.js → index-9sx8tbz2.js} +1 -1
- package/dist/{index-hsabxjz0.js → index-jw81xr75.js} +1 -1
- package/dist/index-y2s6h5bf.js +83 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +667 -56
- package/dist/node.js +26 -26
- package/dist/observability/index.js +22 -22
- package/dist/react.js +2 -2
- package/dist/realtime/contract.d.ts +30 -11
- package/dist/realtime/contract.d.ts.map +1 -1
- package/dist/realtime/index.d.ts +1 -1
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/error-dispatch.d.ts +13 -0
- package/dist/server/error-dispatch.d.ts.map +1 -0
- package/dist/server/index.js +79 -79
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/types.d.ts +6 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing/surface-conformance.d.ts +4 -2
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing.js +122 -111
- package/dist/tools.js +57 -57
- package/llms-full.txt +237 -9
- package/package.json +1 -1
- package/dist/index-es0h4w26.js +0 -63
package/dist/application.js
CHANGED
|
@@ -1065,68 +1065,68 @@ function managedServerResource(config) {
|
|
|
1065
1065
|
});
|
|
1066
1066
|
}
|
|
1067
1067
|
export {
|
|
1068
|
-
|
|
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
|
-
|
|
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":[],"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I,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
|
-
|
|
24
|
-
createCli,
|
|
25
|
-
defineCliCommand,
|
|
26
|
-
emitResult,
|
|
23
|
+
pollUntilDone,
|
|
27
24
|
parseCliArgs,
|
|
28
|
-
|
|
25
|
+
emitResult,
|
|
26
|
+
defineCliCommand,
|
|
27
|
+
createCli,
|
|
28
|
+
DEFAULT_EXIT_CODES
|
|
29
29
|
};
|
package/dist/contract/index.js
CHANGED
|
@@ -23,25 +23,25 @@ import {
|
|
|
23
23
|
} from "../index-f6n5n7nz.js";
|
|
24
24
|
import"../index-ksp6e2ye.js";
|
|
25
25
|
export {
|
|
26
|
-
|
|
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
|
-
|
|
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
|
};
|
package/dist/declaration.d.ts
CHANGED
|
@@ -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":"AAAA
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../src/declaration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,kCAAkC,IAAI,CAAC;AAoBpD,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK/D;AAUD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,aAO3B,CAAC;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,uCAQlC,CAAC;AAEJ,yEAAyE;AACzE,eAAO,MAAM,qBAAqB;;;;;kBAOvB,CAAC;AAEZ;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,aAW9B,CAAC;AAEJ,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,aAEiD,CAAC;AAEpF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB;;;;kBAavB,CAAC;AAEZ,kDAAkD;AAClD,eAAO,MAAM,oBAAoB;;;EAAwC,CAAC;AAoG1E,eAAO,MAAM,oBAAoB;;;kBAKtB,CAAC;AAEZ;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;;;kBAMpC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;kBA0BnB,CAAC;AAEZ;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,uBAAuB;;;;kBAezB,CAAC;AAEZ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,gFAAgF;AAChF,eAAO,MAAM,kBAAkB;;;;;;;;;;;kBAciD,CAAC;AAEjF,0CAA0C;AAC1C,e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ED
|
@@ -157,27 +157,27 @@ function findProjectRole(declaration, name) {
|
|
|
157
157
|
return declaration.roles.find((role) => role.name === name);
|
|
158
158
|
}
|
|
159
159
|
export {
|
|
160
|
-
|
|
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
|
-
|
|
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
|
@@ -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
|
|
113
|
+
if (!value)
|
|
101
114
|
badRequest("Invalid multipart disposition");
|
|
102
|
-
const
|
|
103
|
-
const
|
|
115
|
+
const separator = value.indexOf(";");
|
|
116
|
+
const kind = separator < 0 ? value : value.slice(0, separator);
|
|
117
|
+
if (trimWhitespace(kind).toLowerCase() !== "form-data") {
|
|
118
|
+
badRequest("Invalid multipart disposition");
|
|
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 =
|
|
163
|
+
text = headerDecoder.decode(bytes);
|
|
112
164
|
} catch {
|
|
113
165
|
badRequest("Invalid multipart headers");
|
|
114
166
|
}
|
|
115
|
-
const headers = new
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -906,6 +968,31 @@ function contractStreamResponse(request, context, source, descriptor, operationA
|
|
|
906
968
|
return Promise.resolve(route.handler(request, context));
|
|
907
969
|
}
|
|
908
970
|
|
|
971
|
+
// src/server/error-dispatch.ts
|
|
972
|
+
async function dispatchErrorHooks(config) {
|
|
973
|
+
for (const [scope, hooks] of [
|
|
974
|
+
["group", config.group],
|
|
975
|
+
["global", config.global]
|
|
976
|
+
]) {
|
|
977
|
+
if (!hooks?.onError)
|
|
978
|
+
continue;
|
|
979
|
+
try {
|
|
980
|
+
const response = await hooks.onError(config.context, config.error, config.endpoint);
|
|
981
|
+
if (response instanceof Response)
|
|
982
|
+
return config.respond(response);
|
|
983
|
+
} catch (error) {
|
|
984
|
+
const message = `[stitchkit] ${scope} onError failed`;
|
|
985
|
+
try {
|
|
986
|
+
if (config.logger) {
|
|
987
|
+
config.logger.error(message, { error, traceId: config.context.traceId });
|
|
988
|
+
} else
|
|
989
|
+
console.error(message, error);
|
|
990
|
+
} catch {}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
|
|
909
996
|
// src/server/logger.ts
|
|
910
997
|
var c = {
|
|
911
998
|
reset: "\x1B[0m",
|
|
@@ -1507,7 +1594,7 @@ function createHandler(config) {
|
|
|
1507
1594
|
} catch {}
|
|
1508
1595
|
}
|
|
1509
1596
|
};
|
|
1510
|
-
const respondError = async (err, errCtx, endpoint) => {
|
|
1597
|
+
const respondError = async (err, errCtx, endpoint, group) => {
|
|
1511
1598
|
if (isClientClosedRequest(req, err)) {
|
|
1512
1599
|
const response = applyCors(new Response(null, { status: 499, statusText: "Client Closed Request" }), cors, req);
|
|
1513
1600
|
complete(response.status, undefined, "cancelled");
|
|
@@ -1524,17 +1611,22 @@ function createHandler(config) {
|
|
|
1524
1611
|
details: known?.details
|
|
1525
1612
|
});
|
|
1526
1613
|
};
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1614
|
+
const customResponse = await dispatchErrorHooks({
|
|
1615
|
+
context: errCtx ?? buildErrorContext(req, url, traceId, clientIp),
|
|
1616
|
+
error: err,
|
|
1617
|
+
endpoint,
|
|
1618
|
+
group,
|
|
1619
|
+
global: hooks,
|
|
1620
|
+
logger: customLogger,
|
|
1621
|
+
respond: (response) => {
|
|
1622
|
+
recordFailure();
|
|
1623
|
+
const withCors = applyCors(response, cors, req);
|
|
1624
|
+
complete(withCors.status, errorCode(err));
|
|
1625
|
+
return withCors;
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
if (customResponse)
|
|
1629
|
+
return customResponse;
|
|
1538
1630
|
const appErr = normalizeError(err);
|
|
1539
1631
|
recordFailure(appErr);
|
|
1540
1632
|
complete(appErr.status, appErr.code);
|
|
@@ -1677,7 +1769,7 @@ function createHandler(config) {
|
|
|
1677
1769
|
return body;
|
|
1678
1770
|
} catch (err) {
|
|
1679
1771
|
await multipartLifecycle?.rollback();
|
|
1680
|
-
return respondError(err, ctx, method);
|
|
1772
|
+
return respondError(err, ctx, method, groupHooks);
|
|
1681
1773
|
}
|
|
1682
1774
|
}
|
|
1683
1775
|
return async (req, server) => {
|