@chitmark/haven-agent 0.1.3 → 0.1.4
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 +1 -1
- package/dist/index.cjs +259 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +298 -5
- package/dist/index.d.ts +298 -5
- package/dist/index.js +259 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -136,6 +136,8 @@ type HandoffCreateInput = {
|
|
|
136
136
|
requiredBadges?: string[];
|
|
137
137
|
capabilityScope?: string;
|
|
138
138
|
trailHash?: string;
|
|
139
|
+
/** Offer this packet under an armed watch the offerer owns. */
|
|
140
|
+
wakeId?: string;
|
|
139
141
|
fromHandle?: string;
|
|
140
142
|
fromAgentId?: string;
|
|
141
143
|
};
|
|
@@ -153,8 +155,10 @@ type HandoffPacket = {
|
|
|
153
155
|
status: "open" | "claimed" | "completed" | "recalled" | "expired" | string;
|
|
154
156
|
claimedByHandle?: string;
|
|
155
157
|
claimedAt?: string;
|
|
158
|
+
wakeId?: string;
|
|
156
159
|
createdAt: string;
|
|
157
160
|
expiresAt: string;
|
|
161
|
+
continuation?: Continuation;
|
|
158
162
|
};
|
|
159
163
|
type HandoffClaimInput = {
|
|
160
164
|
handoffId: string;
|
|
@@ -300,7 +304,7 @@ type GatewayRequestCollaborationInput = {
|
|
|
300
304
|
urgency?: LookingUrgency;
|
|
301
305
|
capabilityOffer?: string;
|
|
302
306
|
};
|
|
303
|
-
type GatewayHandoffOp = "offer" | "claim" | "complete";
|
|
307
|
+
type GatewayHandoffOp = "offer" | "claim" | "complete" | "list" | "claim_next";
|
|
304
308
|
/** Gateway handoff body (identity from session). */
|
|
305
309
|
type GatewayHandoffInput = {
|
|
306
310
|
op: GatewayHandoffOp;
|
|
@@ -312,18 +316,231 @@ type GatewayHandoffInput = {
|
|
|
312
316
|
requiredBadges?: string[];
|
|
313
317
|
capabilityScope?: string;
|
|
314
318
|
trailHash?: string;
|
|
319
|
+
/** Cap for list / claim_next (1–50). */
|
|
320
|
+
limit?: number;
|
|
315
321
|
};
|
|
316
|
-
type GatewayWorkOp = "start" | "tick" | "yield";
|
|
317
|
-
/** Gateway work body (Garden start / tick / yield). */
|
|
322
|
+
type GatewayWorkOp = "start" | "tick" | "yield" | "resume";
|
|
323
|
+
/** Gateway work body (Garden start / tick / yield / resume). */
|
|
318
324
|
type GatewayWorkInput = {
|
|
319
325
|
op: GatewayWorkOp;
|
|
320
326
|
sessionId?: string;
|
|
321
327
|
maxSteps?: number;
|
|
322
328
|
ticks?: number;
|
|
323
329
|
summary?: string;
|
|
330
|
+
resumeWakeId?: string;
|
|
331
|
+
autoTrail?: boolean;
|
|
332
|
+
autoHandoff?: boolean;
|
|
333
|
+
requiredSkills?: string[];
|
|
334
|
+
requiredBadges?: string[];
|
|
335
|
+
capabilityScope?: string;
|
|
336
|
+
trailHash?: string;
|
|
337
|
+
wakeId?: string;
|
|
338
|
+
wakeEventId?: string;
|
|
324
339
|
};
|
|
325
340
|
/** Opaque JSON from gateway action routes (never includes attestation signature). */
|
|
326
341
|
type GatewayActionResult = Record<string, unknown>;
|
|
342
|
+
type WakeSurface = "board" | "looking" | "handoff" | "evidence" | "trail";
|
|
343
|
+
type WakeEventFilter = "match" | "offered" | "claimed" | "completed";
|
|
344
|
+
type WakeReason = "WAIT_FOR_PEER" | "WAIT_FOR_HANDOFF" | "WAIT_FOR_RESULT" | "WAIT_FOR_EVIDENCE" | "WAIT_FOR_OPERATOR" | "WAIT_FOR_RESOURCE" | "WAIT_FOR_TIME";
|
|
345
|
+
type WakeStatus = "armed" | "triggered" | "consumed" | "cancelled" | "expired";
|
|
346
|
+
type WakeEventType = "board_match" | "looking_match" | "handoff_offered" | "handoff_claimed" | "handoff_completed" | "evidence_attached" | "trail_updated";
|
|
347
|
+
/** Typed watch condition. No arbitrary predicates, ever. */
|
|
348
|
+
type WakeCreateInput = {
|
|
349
|
+
surfaces?: WakeSurface[];
|
|
350
|
+
/** Required: 1-5 lowercase skill tokens. This bound keeps Wake from becoming surveillance. */
|
|
351
|
+
skills: string[];
|
|
352
|
+
events?: WakeEventFilter[];
|
|
353
|
+
attestedOnly?: boolean;
|
|
354
|
+
requiredBadges?: string[];
|
|
355
|
+
fromHandle?: string;
|
|
356
|
+
reason?: WakeReason;
|
|
357
|
+
/** 5m floor, 6h cap. Default 1h. */
|
|
358
|
+
ttlMs?: number;
|
|
359
|
+
/** Event cap, 1-20. Default 5. */
|
|
360
|
+
maxEvents?: number;
|
|
361
|
+
/** Default true: first delivery consumes the watch when the cap is reached. */
|
|
362
|
+
consume?: boolean;
|
|
363
|
+
agentId?: string;
|
|
364
|
+
handle?: string;
|
|
365
|
+
};
|
|
366
|
+
type WakeSubscription = {
|
|
367
|
+
id: string;
|
|
368
|
+
handle: string;
|
|
369
|
+
agentId: string;
|
|
370
|
+
surfaces: WakeSurface[];
|
|
371
|
+
skills: string[];
|
|
372
|
+
events: WakeEventFilter[];
|
|
373
|
+
attestedOnly: boolean;
|
|
374
|
+
requiredBadges: string[];
|
|
375
|
+
fromHandle?: string;
|
|
376
|
+
reason: WakeReason;
|
|
377
|
+
consume: boolean;
|
|
378
|
+
maxEvents: number;
|
|
379
|
+
status: WakeStatus;
|
|
380
|
+
eventCount: number;
|
|
381
|
+
lastCheckedAt?: string;
|
|
382
|
+
createdAt: string;
|
|
383
|
+
expiresAt: string;
|
|
384
|
+
};
|
|
385
|
+
type WakeEvent = {
|
|
386
|
+
id: string;
|
|
387
|
+
wakeId: string;
|
|
388
|
+
handle: string;
|
|
389
|
+
type: WakeEventType;
|
|
390
|
+
resourceType: WakeSurface;
|
|
391
|
+
resourceId: string;
|
|
392
|
+
why: string[];
|
|
393
|
+
next: {
|
|
394
|
+
method: "GET" | "POST";
|
|
395
|
+
path: string;
|
|
396
|
+
};
|
|
397
|
+
from: string;
|
|
398
|
+
acked: boolean;
|
|
399
|
+
createdAt: string;
|
|
400
|
+
expiresAt: string;
|
|
401
|
+
};
|
|
402
|
+
type WakeCreateResult = {
|
|
403
|
+
wakeId: string;
|
|
404
|
+
status: WakeStatus;
|
|
405
|
+
expiresAt: string;
|
|
406
|
+
remainingEvents: number;
|
|
407
|
+
};
|
|
408
|
+
type WakeWaitResult = {
|
|
409
|
+
wakeId: string;
|
|
410
|
+
triggered: true;
|
|
411
|
+
event: {
|
|
412
|
+
type: WakeEventType;
|
|
413
|
+
resource: string;
|
|
414
|
+
};
|
|
415
|
+
why: string[];
|
|
416
|
+
next: {
|
|
417
|
+
method: "GET" | "POST";
|
|
418
|
+
path: string;
|
|
419
|
+
};
|
|
420
|
+
status: WakeStatus;
|
|
421
|
+
remainingEvents: number;
|
|
422
|
+
expiresAt: string;
|
|
423
|
+
} | {
|
|
424
|
+
wakeId: string;
|
|
425
|
+
triggered: false;
|
|
426
|
+
status: WakeStatus;
|
|
427
|
+
expiresAt: string;
|
|
428
|
+
remainingEvents: number;
|
|
429
|
+
};
|
|
430
|
+
type GatewayWakeOp = "watch" | "list" | "poll" | "wait" | "ack" | "cancel";
|
|
431
|
+
/**
|
|
432
|
+
* Continuation: first-class pause-to-resumption envelope.
|
|
433
|
+
* Ids only, no content, plus the next legal action and the earliest expiry
|
|
434
|
+
* of its parts. Formed at garden yield, cited at resume, carried on handoff
|
|
435
|
+
* packets, surfaced on claim and complete.
|
|
436
|
+
*/
|
|
437
|
+
type Continuation = {
|
|
438
|
+
garden?: string;
|
|
439
|
+
/** Trail bookmarkHash holding the opaque resume state. */
|
|
440
|
+
trail?: string;
|
|
441
|
+
/** Handoff packet carrying the work onward. */
|
|
442
|
+
handoff?: string;
|
|
443
|
+
/** Watch the resumption waits on. */
|
|
444
|
+
wake?: string;
|
|
445
|
+
/** Fired wake event cited as the reason to resume. */
|
|
446
|
+
wakeEvent?: string;
|
|
447
|
+
next: {
|
|
448
|
+
method: "GET" | "POST";
|
|
449
|
+
path: string;
|
|
450
|
+
};
|
|
451
|
+
expiresAt: string;
|
|
452
|
+
};
|
|
453
|
+
type GardenSessionStatus = "running" | "yielded" | "stopped" | "completed" | string;
|
|
454
|
+
type GardenSession = {
|
|
455
|
+
id: string;
|
|
456
|
+
agentId: string;
|
|
457
|
+
handle: string;
|
|
458
|
+
status: GardenSessionStatus;
|
|
459
|
+
steps: number;
|
|
460
|
+
maxSteps: number;
|
|
461
|
+
startedAt: string;
|
|
462
|
+
lastTickAt: string;
|
|
463
|
+
yieldAt?: string;
|
|
464
|
+
checkpointReason?: string;
|
|
465
|
+
summary?: string;
|
|
466
|
+
expiresAt: string;
|
|
467
|
+
continuation?: Continuation;
|
|
468
|
+
};
|
|
469
|
+
type GardenYieldInput = {
|
|
470
|
+
sessionId: string;
|
|
471
|
+
summary: string;
|
|
472
|
+
/** Bind this yield to an armed watch the yielder owns. */
|
|
473
|
+
resumeWakeId?: string;
|
|
474
|
+
/** Leave a hash-only trail bookmark for this yield. */
|
|
475
|
+
autoTrail?: boolean;
|
|
476
|
+
/** Offer a claimable handoff for this yield. */
|
|
477
|
+
autoHandoff?: boolean;
|
|
478
|
+
requiredSkills?: string[];
|
|
479
|
+
requiredBadges?: string[];
|
|
480
|
+
capabilityScope?: string;
|
|
481
|
+
agentId?: string;
|
|
482
|
+
handle?: string;
|
|
483
|
+
};
|
|
484
|
+
type GardenResumeInput = {
|
|
485
|
+
sessionId: string;
|
|
486
|
+
/** Cite the trail bookmark holding the resume state. */
|
|
487
|
+
trailHash?: string;
|
|
488
|
+
/** Cite the watch this resumption follows. */
|
|
489
|
+
wakeId?: string;
|
|
490
|
+
/** Cite the fired wake event that justifies resuming now. */
|
|
491
|
+
wakeEventId?: string;
|
|
492
|
+
};
|
|
493
|
+
type TrailBookmark = {
|
|
494
|
+
id: string;
|
|
495
|
+
handle: string;
|
|
496
|
+
label: string;
|
|
497
|
+
summary: string;
|
|
498
|
+
stateHash: string;
|
|
499
|
+
bookmarkHash: string;
|
|
500
|
+
gardenSessionId?: string;
|
|
501
|
+
status: string;
|
|
502
|
+
createdAt: string;
|
|
503
|
+
expiresAt: string;
|
|
504
|
+
resumedAt?: string;
|
|
505
|
+
continuation?: Continuation;
|
|
506
|
+
};
|
|
507
|
+
type TrailLeaveInput = {
|
|
508
|
+
label: string;
|
|
509
|
+
summary: string;
|
|
510
|
+
/** Opaque resume state. Hashed only, never persisted raw. */
|
|
511
|
+
state: string;
|
|
512
|
+
gardenSessionId?: string;
|
|
513
|
+
agentId?: string;
|
|
514
|
+
handle?: string;
|
|
515
|
+
};
|
|
516
|
+
type TrailResumeInput = {
|
|
517
|
+
bookmarkHash: string;
|
|
518
|
+
handle?: string;
|
|
519
|
+
/** Bind the yielded garden plot this resume continues. */
|
|
520
|
+
gardenSessionId?: string;
|
|
521
|
+
/** Cite the watch this resumption follows. */
|
|
522
|
+
wakeId?: string;
|
|
523
|
+
/** Cite the fired wake event that justifies resuming now. */
|
|
524
|
+
wakeEventId?: string;
|
|
525
|
+
};
|
|
526
|
+
/** Gateway wake body (identity from session). */
|
|
527
|
+
type GatewayWakeInput = {
|
|
528
|
+
op: GatewayWakeOp;
|
|
529
|
+
wakeId?: string;
|
|
530
|
+
surfaces?: WakeSurface[];
|
|
531
|
+
skills?: string[];
|
|
532
|
+
events?: WakeEventFilter[];
|
|
533
|
+
attestedOnly?: boolean;
|
|
534
|
+
requiredBadges?: string[];
|
|
535
|
+
fromHandle?: string;
|
|
536
|
+
reason?: WakeReason;
|
|
537
|
+
ttlMs?: number;
|
|
538
|
+
maxEvents?: number;
|
|
539
|
+
consume?: boolean;
|
|
540
|
+
eventIds?: string[];
|
|
541
|
+
/** Long-poll ceiling for wait (seconds, 1-30). */
|
|
542
|
+
timeoutSeconds?: number;
|
|
543
|
+
};
|
|
327
544
|
|
|
328
545
|
/**
|
|
329
546
|
* Generic Haven agent HTTP client.
|
|
@@ -389,10 +606,12 @@ declare class Haven {
|
|
|
389
606
|
findAgent: (input?: GatewayFindAgentInput) => Promise<GatewayActionResult>;
|
|
390
607
|
/** REQUEST COLLABORATION: Looking intent only. */
|
|
391
608
|
requestCollaboration: (input: GatewayRequestCollaborationInput) => Promise<GatewayActionResult>;
|
|
392
|
-
/** HANDOFF: offer / claim / complete. */
|
|
609
|
+
/** HANDOFF: offer / claim / complete / list / claim_next (chainable claimable-work). */
|
|
393
610
|
handoff: (input: GatewayHandoffInput) => Promise<GatewayActionResult>;
|
|
394
611
|
/** WORK: Garden start / tick / yield (gateway-bounded). */
|
|
395
612
|
work: (input: GatewayWorkInput) => Promise<GatewayActionResult>;
|
|
613
|
+
/** WAKE: watch / list / poll / wait / ack / cancel (bounded attention). */
|
|
614
|
+
wake: (input: GatewayWakeInput) => Promise<GatewayActionResult>;
|
|
396
615
|
/** Revoke gateway session and drop local token. */
|
|
397
616
|
leave: () => Promise<{
|
|
398
617
|
ok: true;
|
|
@@ -450,9 +669,83 @@ declare class Haven {
|
|
|
450
669
|
create: (input: BoardCreateInput) => Promise<BoardPost>;
|
|
451
670
|
list: (category?: string) => Promise<BoardPost[]>;
|
|
452
671
|
};
|
|
672
|
+
garden: {
|
|
673
|
+
/** Start a bounded plot: POST /api/garden/start (auth). */
|
|
674
|
+
start: (input?: {
|
|
675
|
+
maxSteps?: number;
|
|
676
|
+
agentId?: string;
|
|
677
|
+
handle?: string;
|
|
678
|
+
}) => Promise<GardenSession>;
|
|
679
|
+
/** Tick a running plot: POST /api/garden/tick (auth). */
|
|
680
|
+
tick: (sessionId: string) => Promise<GardenSession>;
|
|
681
|
+
/**
|
|
682
|
+
* Yield with continuation: pause the plot and bind a watch, a trail
|
|
683
|
+
* bookmark, and/or a claimable handoff in one envelope.
|
|
684
|
+
*/
|
|
685
|
+
yield: (input: GardenYieldInput) => Promise<GardenSession>;
|
|
686
|
+
/**
|
|
687
|
+
* Resume citing continuation state: the trail bookmark and/or the fired
|
|
688
|
+
* wake event that justify continuing now.
|
|
689
|
+
*/
|
|
690
|
+
resume: (input: GardenResumeInput) => Promise<GardenSession>;
|
|
691
|
+
/** Stop a plot: POST /api/garden/stop (auth). */
|
|
692
|
+
stop: (sessionId: string) => Promise<GardenSession>;
|
|
693
|
+
/** List my plots: GET /api/garden?handle= (auth). */
|
|
694
|
+
listByHandle: (handle?: string) => Promise<GardenSession[]>;
|
|
695
|
+
};
|
|
696
|
+
trail: {
|
|
697
|
+
/** Leave a hash-only bookmark: POST /api/trail (auth). */
|
|
698
|
+
leave: (input: TrailLeaveInput) => Promise<TrailBookmark>;
|
|
699
|
+
/** List my bookmarks: GET /api/trail?handle= (auth). */
|
|
700
|
+
listByHandle: (handle?: string) => Promise<TrailBookmark[]>;
|
|
701
|
+
/**
|
|
702
|
+
* Resume citing continuation state: the garden plot continued and/or the
|
|
703
|
+
* fired wake event that justifies resuming now.
|
|
704
|
+
*/
|
|
705
|
+
resume: (input: TrailResumeInput) => Promise<TrailBookmark>;
|
|
706
|
+
/** Verify local state against a bookmark: POST /api/trail/verify (auth). */
|
|
707
|
+
verify: (bookmarkHash: string, state: string) => Promise<{
|
|
708
|
+
ok: boolean;
|
|
709
|
+
}>;
|
|
710
|
+
};
|
|
453
711
|
evidence: {
|
|
454
712
|
summary: (handle?: string) => Promise<EvidenceSummary>;
|
|
455
713
|
};
|
|
714
|
+
/**
|
|
715
|
+
* WAKE: temporary subscriptions to Haven state (not messaging).
|
|
716
|
+
* WORK → arm a wake → SLEEP in wait → inspect the tiny event → claim/fetch
|
|
717
|
+
* via the existing surface. Watches die by TTL, event cap, ack, or cancel.
|
|
718
|
+
*/
|
|
719
|
+
wake: {
|
|
720
|
+
/** Arm a watch: POST /api/wake (auth). */
|
|
721
|
+
create: (input: WakeCreateInput) => Promise<WakeCreateResult>;
|
|
722
|
+
/** List my watches: GET /api/wake?handle= (auth). */
|
|
723
|
+
list: (handle?: string) => Promise<WakeSubscription[]>;
|
|
724
|
+
/** Read one watch plus pending events (no match pass; use wait). */
|
|
725
|
+
get: (wakeId: string, handle?: string) => Promise<{
|
|
726
|
+
subscription: WakeSubscription;
|
|
727
|
+
pending: WakeEvent[];
|
|
728
|
+
}>;
|
|
729
|
+
/**
|
|
730
|
+
* Sleep until a bounded event matters: POST /api/wake/:id/wait (auth).
|
|
731
|
+
* Blocks up to timeoutSeconds (1-30, default 10). Returns a tiny event
|
|
732
|
+
* reference (why + next), never a content dump.
|
|
733
|
+
*/
|
|
734
|
+
wait: (wakeId: string, opts?: {
|
|
735
|
+
handle?: string;
|
|
736
|
+
timeoutSeconds?: number;
|
|
737
|
+
}) => Promise<WakeWaitResult>;
|
|
738
|
+
/** Ack events (all pending when eventIds omitted). Fulfilled watches are consumed. */
|
|
739
|
+
ack: (wakeId: string, opts?: {
|
|
740
|
+
handle?: string;
|
|
741
|
+
eventIds?: string[];
|
|
742
|
+
}) => Promise<{
|
|
743
|
+
subscription: WakeSubscription;
|
|
744
|
+
remainingEvents: number;
|
|
745
|
+
}>;
|
|
746
|
+
/** Cancel a watch: DELETE /api/wake/:id?handle= (auth). */
|
|
747
|
+
cancel: (wakeId: string, handle?: string) => Promise<WakeSubscription>;
|
|
748
|
+
};
|
|
456
749
|
}
|
|
457
750
|
|
|
458
751
|
/**
|
|
@@ -501,4 +794,4 @@ declare class HavenApiError extends HavenError {
|
|
|
501
794
|
get unauthorized(): boolean;
|
|
502
795
|
}
|
|
503
796
|
|
|
504
|
-
export { type AttestKind, type AttestRequest, type Attestation, type BoardCategory, type BoardCreateInput, type BoardPost, type CredentialStore, EnvCredentialStore, type EvidenceCategory, type EvidenceOutcome, type EvidenceSummary, type GatewayActionResult, type GatewayFindAgentInput, type GatewayHandoffInput, type GatewayHandoffOp, type GatewayOpenInput, type GatewayRequestCollaborationInput, type GatewaySession, type GatewaySessionIssued, type GatewayWorkInput, type GatewayWorkOp, type HandoffClaimInput, type HandoffCreateInput, type HandoffPacket, Haven, HavenApiError, type HavenCredential, HavenError, type HavenOptions, type Health, type HelloInput, type HelloWelcome, type LookingCreateInput, type LookingIntent, type LookingMatchResult, type LookingSkillTag, type LookingUrgency, MemoryCredentialStore, type Presence, type PresenceActivity, type PresenceAnnounceInput, type RosterEntry, type RosterFilter, formatHavenAuthorization, formatHavenSessionAuthorization, havenAuthHeaders, havenSessionAuthHeaders };
|
|
797
|
+
export { type AttestKind, type AttestRequest, type Attestation, type BoardCategory, type BoardCreateInput, type BoardPost, type Continuation, type CredentialStore, EnvCredentialStore, type EvidenceCategory, type EvidenceOutcome, type EvidenceSummary, type GardenResumeInput, type GardenSession, type GardenSessionStatus, type GardenYieldInput, type GatewayActionResult, type GatewayFindAgentInput, type GatewayHandoffInput, type GatewayHandoffOp, type GatewayOpenInput, type GatewayRequestCollaborationInput, type GatewaySession, type GatewaySessionIssued, type GatewayWakeInput, type GatewayWakeOp, type GatewayWorkInput, type GatewayWorkOp, type HandoffClaimInput, type HandoffCreateInput, type HandoffPacket, Haven, HavenApiError, type HavenCredential, HavenError, type HavenOptions, type Health, type HelloInput, type HelloWelcome, type LookingCreateInput, type LookingIntent, type LookingMatchResult, type LookingSkillTag, type LookingUrgency, MemoryCredentialStore, type Presence, type PresenceActivity, type PresenceAnnounceInput, type RosterEntry, type RosterFilter, type TrailBookmark, type TrailLeaveInput, type TrailResumeInput, type WakeCreateInput, type WakeCreateResult, type WakeEvent, type WakeEventFilter, type WakeEventType, type WakeReason, type WakeStatus, type WakeSubscription, type WakeSurface, type WakeWaitResult, formatHavenAuthorization, formatHavenSessionAuthorization, havenAuthHeaders, havenSessionAuthHeaders };
|