@boxxy/model 0.1.6 → 0.1.8
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.d.ts +2 -2
- package/dist/ports/types.d.ts +11 -2
- package/dist/rows/spawn-request-schema.d.ts +2 -1
- package/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/ports/types.ts +13 -4
- package/src/rows/spawn-request-schema.ts +42 -4
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export { relationRowSchema } from './rows/relation-row-schema.ts';
|
|
|
45
45
|
export { reviewCloseOutSchema } from './closeouts/review-close-out-schema.ts';
|
|
46
46
|
export { rowSchemas } from './rows/row-schemas.ts';
|
|
47
47
|
export { signalKey } from './planning/signal-key.ts';
|
|
48
|
-
export { spawnRequestSchema } from './rows/spawn-request-schema.ts';
|
|
48
|
+
export { gitSourceSchema, spawnRequestSchema } from './rows/spawn-request-schema.ts';
|
|
49
49
|
export { stageTimeSchema } from './reports/stage-time-schema.ts';
|
|
50
50
|
export { toJSONValue } from './utils/to-json-value.ts';
|
|
51
51
|
export { triageCloseOutSchema } from './closeouts/triage-close-out-schema.ts';
|
|
@@ -58,7 +58,7 @@ export type { AcceptanceInput, BuildCloseOut, BuildInput, CloseOut, CloseOutAnsw
|
|
|
58
58
|
export type { Claim } from './dispatch/types.ts';
|
|
59
59
|
export type { AnyNewFact, EntityRef, FactEnvelope, FactType, NewFact, OutboxFact, RelationPayload, WorkFacts, } from './facts/types.ts';
|
|
60
60
|
export type { Admission, AdmissionGrant, AdmissionName, Decision, Fault, Filter, Frame, FrameItem, FrameValues, Gate, GateName, Hold, Lift, Limit, LimitFill, Pick, PlanContext, Pool, PropagationLine, SeatRef, SeatRelease, SeatTake, Signal, SignalKey, SignalName, Snapshot, StartPick, View, ViewName, Wait, WaitReason, Waiver, WaiverName, Wake, WakePick, } from './planning/types.ts';
|
|
61
|
-
export type { ApplyResult, Attention, CallerProof, CapacityBackoff, ClaimStore, Clock, FactSink, ForgetOutcome, Forge, HoldNotice, ItemDetailRows, ItemFilter, NewId, NoticeOutcome, Notifier, OutboxReader, PepysAnswer, PepysReader, SinkAnswer, PullRequestReading, RowWrite, SessionFault, SessionReading, SpawnRequest, StartOutcome, StopOutcome, StoreChange, StoreReader, StoreTx, SuspendOutcome, TableName, Tables, WakeSource, WorkerKind, } from './ports/types.ts';
|
|
61
|
+
export type { ApplyResult, Attention, CallerProof, CapacityBackoff, ClaimStore, Clock, FactSink, ForgetOutcome, Forge, GitSource, HoldNotice, ItemDetailRows, ItemFilter, NewId, NoticeOutcome, Notifier, OutboxReader, PepysAnswer, PepysReader, SinkAnswer, PullRequestReading, RowWrite, SessionFault, SessionReading, SpawnRequest, StartOutcome, StopOutcome, StoreChange, StoreReader, StoreTx, SuspendOutcome, TableName, Tables, WakeSource, WorkerKind, } from './ports/types.ts';
|
|
62
62
|
export type { CostToLand, StageTime } from './reports/types.ts';
|
|
63
63
|
export type { OutboxStatus } from './reports/outbox-status.ts';
|
|
64
64
|
export type { ItemSetRows, ItemWithLevers } from './items/types.ts';
|
package/dist/ports/types.d.ts
CHANGED
|
@@ -201,9 +201,17 @@ export type SessionReading = {
|
|
|
201
201
|
readonly kind: 'absent';
|
|
202
202
|
};
|
|
203
203
|
export type Attention = 'working' | 'needs-input' | 'turn-ended';
|
|
204
|
-
export interface
|
|
205
|
-
readonly
|
|
204
|
+
export interface GitSource {
|
|
205
|
+
readonly url: string;
|
|
206
|
+
readonly ref: string;
|
|
207
|
+
}
|
|
208
|
+
export type SpawnRequest = SpawnRequestFields & ({
|
|
206
209
|
readonly cwd: string;
|
|
210
|
+
} | {
|
|
211
|
+
readonly source: GitSource;
|
|
212
|
+
});
|
|
213
|
+
interface SpawnRequestFields {
|
|
214
|
+
readonly target: string;
|
|
207
215
|
readonly prompt: string;
|
|
208
216
|
readonly agent: string;
|
|
209
217
|
readonly model: string;
|
|
@@ -287,3 +295,4 @@ export interface Clock {
|
|
|
287
295
|
now: () => Instant;
|
|
288
296
|
}
|
|
289
297
|
export type NewId = () => string;
|
|
298
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { SpawnRequest } from '../ports/types.ts';
|
|
2
|
+
import type { GitSource, SpawnRequest } from '../ports/types.ts';
|
|
3
|
+
export declare const gitSourceSchema: z.ZodType<GitSource>;
|
|
3
4
|
export declare const spawnRequestSchema: z.ZodType<SpawnRequest>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boxxy/model",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "The types that boxxy's packages share",
|
|
5
5
|
"homepage": "https://github.com/zgeoff/boxxy/tree/main/libs/model#readme",
|
|
6
6
|
"bugs": "https://github.com/zgeoff/boxxy/issues",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typecheck": "tsrs --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@boxxy/content-hash": "0.1.
|
|
34
|
+
"@boxxy/content-hash": "0.1.8",
|
|
35
35
|
"tiny-invariant": "1.3.3",
|
|
36
36
|
"zod": "4.6.7"
|
|
37
37
|
},
|
package/src/index.ts
CHANGED
|
@@ -45,7 +45,7 @@ export { relationRowSchema } from './rows/relation-row-schema.ts';
|
|
|
45
45
|
export { reviewCloseOutSchema } from './closeouts/review-close-out-schema.ts';
|
|
46
46
|
export { rowSchemas } from './rows/row-schemas.ts';
|
|
47
47
|
export { signalKey } from './planning/signal-key.ts';
|
|
48
|
-
export { spawnRequestSchema } from './rows/spawn-request-schema.ts';
|
|
48
|
+
export { gitSourceSchema, spawnRequestSchema } from './rows/spawn-request-schema.ts';
|
|
49
49
|
export { stageTimeSchema } from './reports/stage-time-schema.ts';
|
|
50
50
|
export { toJSONValue } from './utils/to-json-value.ts';
|
|
51
51
|
export { triageCloseOutSchema } from './closeouts/triage-close-out-schema.ts';
|
|
@@ -223,6 +223,7 @@ export type {
|
|
|
223
223
|
FactSink,
|
|
224
224
|
ForgetOutcome,
|
|
225
225
|
Forge,
|
|
226
|
+
GitSource,
|
|
226
227
|
HoldNotice,
|
|
227
228
|
ItemDetailRows,
|
|
228
229
|
ItemFilter,
|
package/src/ports/types.ts
CHANGED
|
@@ -305,12 +305,21 @@ export type SessionReading =
|
|
|
305
305
|
|
|
306
306
|
export type Attention = 'working' | 'needs-input' | 'turn-ended';
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
// A git repository that atc clones on the target. It carries no credential: an imp clones over its
|
|
309
|
+
// own network, where the broker adds the credential from the session's grants.
|
|
310
|
+
export interface GitSource {
|
|
311
|
+
readonly url: string;
|
|
312
|
+
readonly ref: string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Exactly one of the two: `cwd`, the repo's folder on a target on the atc daemon's own host, or
|
|
316
|
+
// `source`, which atc clones into a folder it picks on the target.
|
|
317
|
+
export type SpawnRequest = SpawnRequestFields &
|
|
318
|
+
({ readonly cwd: string } | { readonly source: GitSource });
|
|
319
|
+
|
|
320
|
+
interface SpawnRequestFields {
|
|
309
321
|
// the worker target, such as a host name of the worker kind
|
|
310
322
|
readonly target: string;
|
|
311
|
-
|
|
312
|
-
// the repo's configured path on the target
|
|
313
|
-
readonly cwd: string;
|
|
314
323
|
readonly prompt: string;
|
|
315
324
|
readonly agent: string;
|
|
316
325
|
readonly model: string;
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { SpawnRequest } from '../ports/types.ts';
|
|
2
|
+
import type { GitSource, SpawnRequest } from '../ports/types.ts';
|
|
3
3
|
import { brandSchemas } from './brand-schemas.ts';
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
export const
|
|
5
|
+
// git must never read the URL or the ref as an option, and atc refuses a URL with a credential
|
|
6
|
+
export const gitSourceSchema: z.ZodType<GitSource> = z.strictObject({
|
|
7
|
+
url: z
|
|
8
|
+
.url()
|
|
9
|
+
.max(2048)
|
|
10
|
+
.refine((url) => !url.startsWith('-'), 'a git source url must not start with -')
|
|
11
|
+
.refine((url) => isURLWithoutCredential(url), 'a git source url must carry no credential'),
|
|
12
|
+
ref: z
|
|
13
|
+
.string()
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(255)
|
|
16
|
+
.refine((ref) => !ref.startsWith('-'), 'a git source ref must not start with -'),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const spawnRequestFields = z.strictObject({
|
|
7
20
|
target: z.string().min(1),
|
|
8
|
-
cwd: z.string().min(1),
|
|
9
21
|
prompt: z.string(),
|
|
10
22
|
agent: z.string().min(1),
|
|
11
23
|
model: z.string().min(1),
|
|
@@ -13,3 +25,29 @@ export const spawnRequestSchema: z.ZodType<SpawnRequest> = z.object({
|
|
|
13
25
|
name: z.templateLiteral(['boxxy/', z.string()]),
|
|
14
26
|
idempotencyKey: brandSchemas.attemptId,
|
|
15
27
|
});
|
|
28
|
+
|
|
29
|
+
// The spawn request as the attempt row stores it, read back for a respawn. A request with both a
|
|
30
|
+
// folder and a source, or with neither, fails the parse.
|
|
31
|
+
export const spawnRequestSchema: z.ZodType<SpawnRequest> = spawnRequestFields
|
|
32
|
+
.extend({ cwd: z.string().min(1).optional(), source: gitSourceSchema.optional() })
|
|
33
|
+
.transform((request, ctx): SpawnRequest => {
|
|
34
|
+
const { cwd, source, ...fields } = request;
|
|
35
|
+
|
|
36
|
+
if (cwd !== undefined && source === undefined) {
|
|
37
|
+
return { ...fields, cwd };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (source !== undefined && cwd === undefined) {
|
|
41
|
+
return { ...fields, source };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ctx.addIssue({ code: 'custom', message: 'a spawn request takes a cwd or a source, not both' });
|
|
45
|
+
|
|
46
|
+
return z.NEVER;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
function isURLWithoutCredential(url: string): boolean {
|
|
50
|
+
const parsed = URL.parse(url);
|
|
51
|
+
|
|
52
|
+
return parsed !== null && parsed.username === '' && parsed.password === '';
|
|
53
|
+
}
|