@robota-sdk/agent-product 3.6.0 → 3.7.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.
@@ -126,6 +126,13 @@ declare class KnowledgeWiki {
126
126
  constructor(options: IKnowledgeWikiOptions);
127
127
  private claimId;
128
128
  remember(raw: IRememberInput): Promise<IRememberResult>;
129
+ /**
130
+ * File a fact through the validated connector adapter. This path only accepts connector provenance
131
+ * and checks for secret values, so security vocabulary in an external fact is not refused. It is
132
+ * deliberately not exposed through the model-facing wiki tool; that path remains strict.
133
+ */
134
+ rememberConnectorFact(raw: IRememberInput): Promise<IRememberResult>;
135
+ private rememberWithCheck;
129
136
  read(id: string): Promise<IWikiPage | undefined>;
130
137
  list(): Promise<readonly IWikiPage[]>;
131
138
  search(query: string, limit?: number): Promise<readonly ISearchHit[]>;
@@ -293,6 +300,21 @@ interface IGoal {
293
300
  readonly readOnly: boolean;
294
301
  /** The connector this goal keeps in sync, when it is one: a person's own goals have none. */
295
302
  readonly connectorId?: string;
303
+ /** The case this goal gives a turn on, when it is one: found by this id, and run again for each answer. */
304
+ readonly caseId?: string;
305
+ /** An accepted case answer awaiting a turn, owned by the agent holding its authority snapshot. */
306
+ readonly pendingCaseAnswer?: {
307
+ readonly feedItemId: string;
308
+ readonly ownerId: string;
309
+ };
310
+ /** The agent and answer associated with a claimed case turn. */
311
+ readonly activeCaseRun?: {
312
+ readonly runId: string;
313
+ readonly ownerId: string;
314
+ readonly answerId: string;
315
+ };
316
+ /** The most recent case answer whose turn has started. */
317
+ readonly lastCaseAnswerId?: string;
296
318
  readonly status: TGoalStatus;
297
319
  /** When the goal is next due (ISO 8601); absent when it is not scheduled. */
298
320
  readonly nextRunAt?: string;
@@ -312,6 +334,10 @@ type TGoalRunOutcome = 'done' | 'failed' | 'interrupted';
312
334
  interface IGoalRun {
313
335
  readonly id: string;
314
336
  readonly goalId: string;
337
+ readonly caseAnswerId?: string;
338
+ readonly caseOwnerId?: string;
339
+ readonly resumeAfterShutdown?: true;
340
+ readonly caseReport?: 'pending' | 'recorded' | 'quiet';
315
341
  readonly startedAt: string;
316
342
  readonly endedAt?: string;
317
343
  readonly outcome?: TGoalRunOutcome;
@@ -319,8 +345,31 @@ interface IGoalRun {
319
345
  readonly report?: string;
320
346
  readonly actions: readonly IGoalAction[];
321
347
  }
322
- type TFeedKind = 'report' | 'approval' | 'notice';
348
+ type TFeedKind = 'report' | 'approval' | 'notice' | 'question';
323
349
  type TApprovalState = 'pending' | 'approved' | 'denied' | 'expired';
350
+ /** A question is open until the person answers it, or withdrawn when its case closes first. */
351
+ type TQuestionState = 'open' | 'answered' | 'withdrawn';
352
+ /** What the person answered: one of the offered choices, or a reply in their own words. */
353
+ interface IQuestionAnswer {
354
+ readonly choice?: string;
355
+ readonly reply?: string;
356
+ readonly at: string;
357
+ }
358
+ /** The question the agent asks from a case, and where it stands. Never approved, only answered. */
359
+ interface IFeedQuestion {
360
+ readonly caseId: string;
361
+ readonly text: string;
362
+ readonly options: readonly string[];
363
+ readonly allowsReply: boolean;
364
+ readonly state: TQuestionState;
365
+ readonly answer?: IQuestionAnswer;
366
+ /**
367
+ * How the case closed, when it closed right after this answer: shown under the answer so a close the
368
+ * person would want to know about is not left in the case's thread alone. Written by the agent from
369
+ * content other people wrote, so a host shows it as plain text.
370
+ */
371
+ readonly resolution?: string;
372
+ }
324
373
  interface IFeedItem {
325
374
  readonly id: string;
326
375
  readonly at: string;
@@ -335,10 +384,14 @@ interface IFeedItem {
335
384
  readonly detail: string;
336
385
  readonly state: TApprovalState;
337
386
  };
387
+ /** Present on a question: what the agent asks the person about one of its cases. */
388
+ readonly question?: IFeedQuestion;
338
389
  readonly dismissed: boolean;
339
390
  }
340
391
  /** Where goals, their runs and the feed live; a host supplies one per principal. */
341
392
  interface IGoalStore {
393
+ /** The file store synchronizes feed replacements before exposing them to a host. */
394
+ readonly durableFeedWrites?: true;
342
395
  listGoals(): Promise<readonly IGoal[]>;
343
396
  getGoal(id: string): Promise<IGoal | undefined>;
344
397
  putGoal(goal: IGoal): Promise<void>;
@@ -346,7 +399,9 @@ interface IGoalStore {
346
399
  putRun(run: IGoalRun): Promise<void>;
347
400
  /** A goal's runs, newest first. */
348
401
  listRuns(goalId: string, limit: number): Promise<readonly IGoalRun[]>;
349
- putFeedItem(item: IFeedItem): Promise<void>;
402
+ putFeedItem(item: IFeedItem, options?: {
403
+ readonly cancelApproved?: boolean;
404
+ }): Promise<void>;
350
405
  getFeedItem(id: string): Promise<IFeedItem | undefined>;
351
406
  /** Feed items, newest first. */
352
407
  listFeed(limit: number): Promise<readonly IFeedItem[]>;
@@ -356,6 +411,10 @@ interface IGoalStore {
356
411
  interface IGoalBookOptions {
357
412
  readonly store: IGoalStore;
358
413
  readonly now?: () => Date;
414
+ /** Serialize goal and run mutations across hosts sharing the store. */
415
+ readonly withWriteLock?: <T>(work: () => Promise<T>) => Promise<T>;
416
+ /** Coordinate removing a goal with the host's pending work for it. */
417
+ readonly withRemoveLock?: (id: string, work: () => Promise<void>) => Promise<void>;
359
418
  }
360
419
  interface ICreateGoalInput {
361
420
  readonly title: string;
@@ -363,38 +422,85 @@ interface ICreateGoalInput {
363
422
  readonly everyMinutes?: number;
364
423
  readonly readOnly?: boolean;
365
424
  readonly connectorId?: string;
425
+ readonly caseId?: string;
366
426
  }
367
427
  declare class GoalRefusedError extends Error {
368
428
  constructor(reason: string);
369
429
  }
370
430
  declare class GoalBook {
431
+ /** This book allocates feed identifiers independently across host processes. */
432
+ readonly usesUniqueFeedIds: true;
433
+ readonly supportsSharedGoalLock: true;
434
+ readonly supportsCaseAnswerQueue: true;
435
+ readonly supportsCaseInterruptionRecovery: true;
436
+ readonly supportsCaseRunOwnership: true;
437
+ readonly supportsCaseReportRecovery: true;
438
+ readonly supportsCaseRunIdentityRecovery: true;
439
+ readonly supportsCoordinatedRemoval: true;
371
440
  private readonly store;
372
441
  private readonly now;
442
+ private readonly withWriteLock;
443
+ private readonly withRemoveLock;
444
+ private tail;
373
445
  private sequence;
374
446
  constructor(options: IGoalBookOptions);
447
+ private exclusive;
375
448
  private stamp;
376
449
  private mint;
377
450
  private require;
378
451
  private save;
379
452
  create(input: ICreateGoalInput): Promise<IGoal>;
453
+ private createUnlocked;
454
+ /** Queue one answer for the agent holding its answer-time authority. */
455
+ enqueueCaseAnswer(input: {
456
+ readonly caseId: string;
457
+ readonly feedItemId: string;
458
+ readonly ownerId: string;
459
+ readonly title: string;
460
+ readonly instructions: string;
461
+ }): Promise<IGoal>;
462
+ /** Transfer only a still-pending answer whose original owner has been proven stopped. */
463
+ adoptCaseAnswer(id: string, previousOwner: string, ownerId: string): Promise<boolean>;
464
+ private settleUnclaimedCaseRun;
465
+ /** Recover a case run only after its particular owner has been proven stopped. */
466
+ recoverCaseOwner(id: string, previousOwner: string, ownerId: string, expectedRunId: string): Promise<boolean>;
467
+ private recordCaseReport;
380
468
  list(): Promise<readonly IGoal[]>;
381
469
  get(id: string): Promise<IGoal | undefined>;
382
470
  runs(goalId: string, limit?: number): Promise<readonly IGoalRun[]>;
383
471
  /** Goals due now: active and scheduled at or before this moment. */
384
472
  due(): Promise<readonly IGoal[]>;
385
473
  pause(id: string): Promise<IGoal>;
474
+ private pauseUnlocked;
386
475
  /**
387
476
  * Change how often a goal repeats. A run in progress keeps going and the next one follows the new
388
477
  * interval; otherwise the goal is active again and due that long after its last run (at once if it
389
478
  * never ran or that moment has passed).
390
479
  */
391
480
  reschedule(id: string, everyMinutes: number): Promise<IGoal>;
481
+ private rescheduleUnlocked;
392
482
  /** Make a paused, finished or failed goal due now. */
393
483
  resume(id: string): Promise<IGoal>;
484
+ private resumeUnlocked;
485
+ /**
486
+ * Make a goal that has finished due now again, as a one-shot goal's next turn: a case's goal runs once
487
+ * for each answer. A goal still running or waiting is refused, since a second run would start before
488
+ * the first ended, and so is a paused one, which the person stopped; `resume` is for them. The interval
489
+ * is untouched, so a scheduled goal follows its own schedule again once the extra run ends.
490
+ */
491
+ runAgain(id: string): Promise<IGoal>;
492
+ private runAgainUnlocked;
394
493
  remove(id: string): Promise<void>;
395
- startRun(goalId: string): Promise<IGoalRun>;
494
+ private removeUnlocked;
495
+ startRun(goalId: string, options?: {
496
+ readonly requireDue?: boolean;
497
+ readonly ownerId?: string;
498
+ }): Promise<IGoalRun>;
499
+ private startRunUnlocked;
396
500
  recordAction(run: IGoalRun, action: Omit<IGoalAction, 'at'>): Promise<IGoalRun>;
501
+ private recordActionUnlocked;
397
502
  setWaiting(goalId: string, waiting: boolean): Promise<void>;
503
+ private setWaitingUnlocked;
398
504
  /** End a run, schedule the next one or close the goal, and report to the feed. */
399
505
  /**
400
506
  * End a run. A `quiet` run that went well is kept in the goal's history but is not posted to the
@@ -402,19 +508,558 @@ declare class GoalBook {
402
508
  */
403
509
  finishRun(run: IGoalRun, outcome: TGoalRunOutcome, report: string, options?: {
404
510
  readonly quiet?: boolean;
511
+ readonly resumeCaseOwner?: string;
405
512
  }): Promise<IGoalRun>;
513
+ private finishRunUnlocked;
406
514
  /**
407
515
  * After the host restarts, nothing is running: a goal it was running is due again, and an approval
408
516
  * it was waiting on can no longer be answered.
409
517
  */
410
518
  recover(): Promise<number>;
519
+ private recoverUnlocked;
520
+ /** Recover one goal only when its host has proved no live agent owns it. */
521
+ recoverGoal(id: string, options?: {
522
+ readonly adoptOwner?: string;
523
+ }): Promise<boolean>;
524
+ private recoverGoalUnlocked;
411
525
  post(item: Omit<IFeedItem, 'id' | 'at' | 'dismissed'>): Promise<IFeedItem>;
412
526
  feed(limit?: number): Promise<readonly IFeedItem[]>;
413
527
  feedItem(id: string): Promise<IFeedItem | undefined>;
414
528
  setApproval(id: string, state: TApprovalState): Promise<IFeedItem>;
529
+ /** Expire this exact approval after its prompt was cancelled before the action could start. */
530
+ cancelApproval(id: string, expected: {
531
+ readonly goalId: string | undefined;
532
+ readonly runId: string | undefined;
533
+ readonly tool: string;
534
+ readonly detail: string;
535
+ }): Promise<void>;
536
+ /** Record the person's answer to a question; a question is answered once. */
537
+ answerQuestion(id: string, answer: Omit<IQuestionAnswer, 'at'>): Promise<IFeedItem>;
538
+ /** Show how the case closed under the person's answer; only an answered question carries one. */
539
+ resolveQuestion(id: string, resolution: string): Promise<IFeedItem>;
540
+ /** A question whose case closed before the person answered it can no longer be answered. */
541
+ withdrawQuestion(id: string): Promise<IFeedItem>;
415
542
  dismiss(id: string): Promise<void>;
416
543
  }
417
544
  //#endregion
545
+ //#region src/personal/cases/types.d.ts
546
+ /**
547
+ * Cases: a thread of thought the agent opens from something it noticed, asks the person about, and
548
+ * keeps until it is settled. A case is not a chat and not a goal: it is the agent's own record of one
549
+ * matter (what it saw, what it noted, the one question it is waiting on, and what happened), kept
550
+ * beside the goals and the feed the question is shown in.
551
+ */
552
+ type TCaseState = 'open' | 'closed';
553
+ type TCaseEventKind = 'observed' | 'noted' | 'asked' | 'answered' | 'closed';
554
+ /**
555
+ * How soon the agent suggests a question be put to the person: `now` for what needs them soon, `digest`
556
+ * for what can wait for a daily summary, `feed` for the rest. It is only a suggestion: what actually
557
+ * reaches the person is decided by their own delivery limits.
558
+ */
559
+ type TCaseUrgency = 'now' | 'digest' | 'feed';
560
+ /** Where a case came from: the service that showed it and the agent's own stable reference to the item. */
561
+ interface ICaseOrigin {
562
+ readonly connectorId?: string;
563
+ /** The same reference for the same item every time, so one source never opens two cases. */
564
+ readonly source: string;
565
+ }
566
+ interface ICaseNote {
567
+ readonly at: string;
568
+ readonly text: string;
569
+ }
570
+ /** The question a case is waiting on; at most one at a time. */
571
+ interface ICaseQuestion {
572
+ readonly text: string;
573
+ /** The answers the person may pick; empty when only a reply is wanted. */
574
+ readonly options: readonly string[];
575
+ readonly allowsReply: boolean;
576
+ readonly askedAt: string;
577
+ /** The feed item that shows the question to the person. */
578
+ readonly feedItemId: string;
579
+ /** The agent's suggestion of how urgent the question is; absent in a case written before it existed, which reads as `feed`. */
580
+ readonly urgency?: TCaseUrgency;
581
+ }
582
+ /** What happened on the case, oldest first. */
583
+ interface ICaseEvent {
584
+ readonly at: string;
585
+ readonly kind: TCaseEventKind;
586
+ readonly text: string;
587
+ }
588
+ interface ICase {
589
+ readonly id: string;
590
+ readonly title: string;
591
+ readonly origin: ICaseOrigin;
592
+ readonly state: TCaseState;
593
+ /** The agent's running notes, oldest first; what a question shows as its evidence. */
594
+ readonly notes: readonly ICaseNote[];
595
+ readonly question?: ICaseQuestion;
596
+ /**
597
+ * The feed item that showed the question the person answered last; it is where the case's resolution
598
+ * is shown if the case closes after that answer. Absent until a question is answered, and in a case
599
+ * written before it existed, where there is nothing to show it on.
600
+ */
601
+ readonly lastAnsweredFeedItemId?: string;
602
+ readonly history: readonly ICaseEvent[];
603
+ readonly createdAt: string;
604
+ readonly updatedAt: string;
605
+ }
606
+ /** Where cases live; a host supplies one per principal. */
607
+ interface ICaseStore {
608
+ list(): Promise<readonly ICase[]>;
609
+ get(id: string): Promise<ICase | undefined>;
610
+ put(item: ICase): Promise<void>;
611
+ }
612
+ //#endregion
613
+ //#region src/personal/cases/case-book.d.ts
614
+ declare const CASE_URGENCIES: readonly TCaseUrgency[];
615
+ declare class CaseRefusedError extends Error {
616
+ constructor(reason: string);
617
+ }
618
+ /** What a host is told when a question was asked: the case, the card that shows it, and the urgency suggested. */
619
+ interface ICaseAskedEvent {
620
+ readonly case: ICase;
621
+ readonly item: IFeedItem;
622
+ readonly urgency: TCaseUrgency;
623
+ }
624
+ interface ICaseAnswerEvent {
625
+ readonly before: ICase;
626
+ readonly after: ICase;
627
+ readonly item: IFeedItem;
628
+ readonly answer: IAnswerInput;
629
+ }
630
+ interface ICaseBookOptions {
631
+ readonly store: ICaseStore;
632
+ /** Serialize complete case mutations across hosts that share the store and feed. */
633
+ readonly withWriteLock?: <T>(work: () => Promise<T>) => Promise<T>;
634
+ /** Where a question is shown to the person, and where their answer is recorded. */
635
+ readonly feed: GoalBook;
636
+ /**
637
+ * Called once a question has been asked and written. It is not waited for and cannot fail the ask: a
638
+ * question is already in the feed when this runs, whatever the host does about telling the person.
639
+ */
640
+ readonly onAsked?: (event: ICaseAskedEvent) => void | Promise<void>;
641
+ /** Called after a case has closed and its write lock has been released. */
642
+ readonly onClosed?: (closed: ICase) => void | Promise<void>;
643
+ readonly answerHooks?: {
644
+ before(feedItemId: string): Promise<void>;
645
+ prepare(event: ICaseAnswerEvent): Promise<void>;
646
+ persistCase(): Promise<void>;
647
+ committed(event: ICaseAnswerEvent, context: unknown): Promise<void>;
648
+ };
649
+ readonly now?: () => Date;
650
+ }
651
+ interface IOpenCaseInput {
652
+ readonly title: string;
653
+ /** What was noticed and why it matters; the case's first note. */
654
+ readonly noticed: string;
655
+ /** The agent's own stable reference to the item, so the same item opens one case. */
656
+ readonly source: string;
657
+ readonly connectorId?: string;
658
+ }
659
+ interface IAskInput {
660
+ readonly question: string;
661
+ readonly options?: readonly string[];
662
+ /** Whether the person may answer in their own words; by default, when there are no choices. */
663
+ readonly allowsReply?: boolean;
664
+ /** How urgent the agent suggests the question is; `feed` when it says nothing. */
665
+ readonly urgency?: string;
666
+ }
667
+ interface IAnswerInput {
668
+ readonly choice?: string;
669
+ readonly reply?: string;
670
+ }
671
+ declare class CaseBook {
672
+ /** This book serializes a complete mutation with the host's write lock. */
673
+ readonly supportsSharedWriteLock: true;
674
+ readonly supportsCaseAnswerHooks: true;
675
+ readonly supportsAnswerScopedWrites: true;
676
+ private readonly store;
677
+ private readonly feed;
678
+ private readonly onAsked;
679
+ private readonly onClosed;
680
+ private readonly answerHooks;
681
+ private readonly now;
682
+ private readonly withWriteLock;
683
+ private tail;
684
+ constructor(options: ICaseBookOptions);
685
+ /** Tell the host a question was asked, without waiting for it and without letting it fail the ask. */
686
+ private announce;
687
+ private stamp;
688
+ /** One write at a time, so two calls in one turn cannot both pass a check the other changes. */
689
+ private exclusive;
690
+ private require;
691
+ private requireOpen;
692
+ /** A card that still looks open although its case moved on becomes a withdrawn one, which can be dismissed. */
693
+ private stale;
694
+ private requireRoom;
695
+ /** Open a case, or return the one this source already opened, open or closed. */
696
+ open(input: IOpenCaseInput): Promise<{
697
+ readonly case: ICase;
698
+ readonly existing: boolean;
699
+ }>;
700
+ private requireAnswer;
701
+ note(id: string, text: string, options?: {
702
+ readonly answerId: string;
703
+ }): Promise<ICase>;
704
+ /** Ask the person the case's one question; it shows in their feed with the notes as its evidence. */
705
+ ask(id: string, input: IAskInput, scope?: {
706
+ readonly answerId: string;
707
+ }): Promise<{
708
+ readonly case: ICase;
709
+ readonly item: IFeedItem;
710
+ }>;
711
+ /**
712
+ * Record the person's answer to a question in the feed: one of its choices, or a reply when the
713
+ * question allows one. The case moves on with no question waiting; what to do next is not decided here.
714
+ */
715
+ answer(feedItemId: string, input: IAnswerInput, options?: {
716
+ readonly context: unknown;
717
+ }): Promise<{
718
+ readonly case: ICase;
719
+ readonly item: IFeedItem;
720
+ }>;
721
+ /**
722
+ * Settle a case with a one-line resolution. A question still waiting is withdrawn from the feed; with
723
+ * none waiting, the resolution is shown on the card of the question the person answered last, so a
724
+ * close that matters to them (the agent telling them to go to the service directly, say) is not left
725
+ * in the case's thread alone. The case is written first: if that fails nothing changed and the case
726
+ * still waits on a visible card, and if the withdrawal fails the case is closed and its card is
727
+ * withdrawn when the person next answers it.
728
+ */
729
+ close(id: string, resolution: string, options?: {
730
+ readonly answerId: string;
731
+ }): Promise<ICase>;
732
+ /**
733
+ * The card shows a copy of what the closed case already holds, so a card that cannot take it is left
734
+ * as it is: failing the close here would tell the agent a close that happened had not, and a second
735
+ * close is refused, so nothing could be retried. The resolution stays in the case's thread.
736
+ */
737
+ private showResolution;
738
+ get(id: string): Promise<ICase | undefined>;
739
+ /** Open cases first, then the ones closed last; each newest first. */
740
+ list(limit?: number): Promise<readonly ICase[]>;
741
+ }
742
+ //#endregion
743
+ //#region src/personal/cases/stores.d.ts
744
+ declare function createMemoryCaseStore(): ICaseStore;
745
+ declare function createFileCaseStore(directory: string): ICaseStore;
746
+ //#endregion
747
+ //#region src/personal/cases/tools.d.ts
748
+ declare const CASE_TOOL_NAMES: {
749
+ readonly open: "CaseOpen";
750
+ readonly note: "CaseNote";
751
+ readonly ask: "CaseAsk";
752
+ readonly close: "CaseClose";
753
+ };
754
+ declare function createCaseTools(book: CaseBook, scope?: {
755
+ readonly caseId: string;
756
+ readonly answerId: string;
757
+ }): FunctionTool[];
758
+ declare const CASE_INSTRUCTIONS: string;
759
+ //#endregion
760
+ //#region src/personal/cases/turn.d.ts
761
+ /**
762
+ * The tools a case turn has by default: it may look at the connector and the library to check
763
+ * something related, and keep the case. A host may add its own scoped action separately.
764
+ */
765
+ declare function caseTurnTools(): string[];
766
+ /**
767
+ * What a case turn is asked, as the goal's own text: short, and shown to the person with the goal. It
768
+ * carries no case text, since the title was written by the agent from content other people wrote.
769
+ */
770
+ declare function caseTurnPrompt(): string;
771
+ /**
772
+ * What a case turn is told about how to work, for this turn: the person's answer and what to do. The
773
+ * title, the question and the notes were written by the agent from content other people wrote, so they
774
+ * come after the label that says so, and the directions come after them; only the case id and the
775
+ * person's own answer stand before it.
776
+ */
777
+ declare function caseTurnInstructions(found: ICase, options?: {
778
+ readonly allowApprovedActions?: boolean;
779
+ }): string;
780
+ //#endregion
781
+ //#region src/personal/delivery/types.d.ts
782
+ /** Times are `HH:MM` on a 24-hour clock, in the local time of the machine that runs the agent. */
783
+ interface IQuietHours {
784
+ readonly enabled: boolean;
785
+ readonly from: string;
786
+ readonly to: string;
787
+ }
788
+ interface IDigestSchedule {
789
+ readonly enabled: boolean;
790
+ readonly at: string;
791
+ }
792
+ /** The person's limits. Local time throughout: that of the machine running the agent. */
793
+ interface IDeliverySettings {
794
+ /** How many questions may be pushed immediately in one local day, 0 to 20; 0 pushes none. */
795
+ readonly dailyLimit: number;
796
+ /** While it lasts nothing is pushed immediately; a window may cross midnight. */
797
+ readonly quietHours: IQuietHours;
798
+ /** Whether questions that can wait are gathered into one daily summary, and when it goes out. */
799
+ readonly digest: IDigestSchedule;
800
+ }
801
+ /** What delivery remembers between runs. */
802
+ interface IDeliveryState {
803
+ /** The local day `sent` counts, as `YYYY-MM-DD`. */
804
+ readonly day: string;
805
+ /** How many questions were pushed immediately on `day`. */
806
+ readonly sent: number;
807
+ /** The local day the last digest went out. */
808
+ readonly digestedOn?: string;
809
+ /** Feed items waiting for the next digest. */
810
+ readonly pendingDigest: readonly string[];
811
+ }
812
+ /** What becomes of one question: pushed now, held for the daily summary, or left in the feed. */
813
+ type TDelivery = 'notify' | 'digest' | 'feed';
814
+ interface IDeliveryMessage {
815
+ /** A `test` message is the person's own check that a sink works; it is never a question. */
816
+ readonly kind: 'question' | 'digest' | 'test';
817
+ /** A short plain line that says what the message is about, for a sink that shows a heading. */
818
+ readonly title: string;
819
+ /** Plain text on one or a few lines; a sink adds nothing to it. */
820
+ readonly text: string;
821
+ }
822
+ /**
823
+ * Somewhere a message can be pushed to: the person's connected messengers, an address they gave, a page
824
+ * they have open. A sink that cannot take a message throws, which is how a push is told from one that
825
+ * was not taken.
826
+ */
827
+ interface IDeliverySink {
828
+ readonly id: string;
829
+ deliver(message: IDeliveryMessage): Promise<void>;
830
+ }
831
+ /** Where one value lives between runs; a host supplies one for each. */
832
+ interface IDeliveryStore<T> {
833
+ /** The stored value, or `undefined` when nothing was stored yet. */
834
+ read(): Promise<T | undefined>;
835
+ write(value: T): Promise<void>;
836
+ }
837
+ /** What the person sees of delivery: their limits, today's pushes against them, and what waits for the digest. */
838
+ interface IDeliveryStatus {
839
+ readonly settings: IDeliverySettings;
840
+ readonly today: {
841
+ readonly sent: number;
842
+ readonly limit: number;
843
+ };
844
+ /** Open questions held for the next digest. */
845
+ readonly waitingInDigest: number;
846
+ }
847
+ /** The feed as delivery needs it: a card, looked up again before a digest names it. */
848
+ interface IDeliveryFeed {
849
+ feedItem(id: string): Promise<IFeedItem | undefined>;
850
+ }
851
+ //#endregion
852
+ //#region src/personal/delivery/policy.d.ts
853
+ declare const DAILY_LIMIT_MAX = 20;
854
+ declare const DEFAULT_DELIVERY_SETTINGS: IDeliverySettings;
855
+ declare class DeliveryRefusedError extends Error {
856
+ constructor(reason: string);
857
+ }
858
+ interface IDecideDeliveryInput {
859
+ readonly urgency: TCaseUrgency;
860
+ readonly now: Date;
861
+ readonly settings: IDeliverySettings;
862
+ /** How many questions were already pushed immediately on the local day of `now`. */
863
+ readonly sentToday: number;
864
+ }
865
+ /**
866
+ * `feed` stays in the feed. `digest` waits for the daily summary, or stays in the feed when there is
867
+ * none. `now` is pushed unless the person's quiet hours or daily limit say otherwise, and then it is
868
+ * held like a `digest`.
869
+ */
870
+ declare function decideDelivery(input: IDecideDeliveryInput): TDelivery;
871
+ //#endregion
872
+ //#region src/personal/delivery/browser-outbox.d.ts
873
+ /** How many messages are kept; an older one is dropped for a new one. */
874
+ declare const BROWSER_OUTBOX_CAPACITY = 20;
875
+ /** How long after its last poll a page still counts as open. */
876
+ declare const BROWSER_LISTENING_MS = 90000;
877
+ interface IBrowserNotification {
878
+ /** Counts up from 1 for as long as the agent runs, so a page asks for what came after the last one it saw. */
879
+ readonly id: number;
880
+ readonly at: string;
881
+ readonly kind: IDeliveryMessage['kind'];
882
+ readonly title: string;
883
+ readonly text: string;
884
+ }
885
+ interface IBrowserOutboxOptions {
886
+ /** Milliseconds, on the clock the page's polls are counted by. */
887
+ readonly now?: () => number;
888
+ readonly capacity?: number;
889
+ readonly listeningMs?: number;
890
+ }
891
+ declare class BrowserOutbox implements IDeliverySink {
892
+ readonly id = "browser";
893
+ private readonly now;
894
+ private readonly capacity;
895
+ private readonly listeningMs;
896
+ private messages;
897
+ private latest;
898
+ private polledAt;
899
+ constructor(options?: IBrowserOutboxOptions);
900
+ /** Whether a page has polled lately enough to be open. */
901
+ listening(): boolean;
902
+ /** Keeps the message for the page to fetch, or throws when no page is open to take it. */
903
+ deliver(message: IDeliveryMessage): Promise<void>;
904
+ /**
905
+ * A page asks what came after the last message it saw; that it asked is what shows a page is open.
906
+ * A page with nothing yet asks from now on and gets none; one that remembers a later message than any
907
+ * here, as after a restart, gets everything kept.
908
+ */
909
+ poll(after?: number): {
910
+ readonly messages: readonly IBrowserNotification[];
911
+ readonly latest: number;
912
+ };
913
+ }
914
+ //#endregion
915
+ //#region src/personal/delivery/notification-address.d.ts
916
+ declare const WEBHOOK_FORMATS: readonly ["plain", "json"];
917
+ type TWebhookFormat = (typeof WEBHOOK_FORMATS)[number];
918
+ /** The address as kept, and how a message is written to it. */
919
+ interface IWebhookTarget {
920
+ readonly url: string;
921
+ readonly format: TWebhookFormat;
922
+ }
923
+ /** Where the address lives between runs; a host supplies one. Only this module reads it. */
924
+ interface IWebhookStore {
925
+ read(): Promise<IWebhookTarget | undefined>;
926
+ write(value: IWebhookTarget): Promise<void>;
927
+ clear(): Promise<void>;
928
+ }
929
+ interface IWebhookRequest {
930
+ readonly url: string;
931
+ readonly headers: Readonly<Record<string, string>>;
932
+ readonly body: string;
933
+ /** The whole exchange, answer included, is given up after this long. */
934
+ readonly timeoutMs: number;
935
+ }
936
+ /** The status of the answer, or why the destination was not reached; the words name no address. */
937
+ type TWebhookAnswer = {
938
+ readonly status: number;
939
+ } | {
940
+ readonly refused: string;
941
+ };
942
+ /** What the host lends for the network: its outbound-request policy and its way to send. */
943
+ interface IWebhookTransport {
944
+ /** Why this destination may not be reached, or `undefined` when it may. Words name no address. */
945
+ admit(url: URL): Promise<string | undefined>;
946
+ /**
947
+ * One request to the address, which is judged by the same policy again, with no redirect followed. It
948
+ * throws when the destination cannot be reached or does not answer in time.
949
+ */
950
+ post(request: IWebhookRequest): Promise<TWebhookAnswer>;
951
+ }
952
+ /** What the person is told about the address: never the address itself. */
953
+ interface INotificationAddressView {
954
+ readonly configured: boolean;
955
+ /** The host (and port) the notifications go to; present only when one is set. */
956
+ readonly host?: string;
957
+ readonly format: TWebhookFormat;
958
+ }
959
+ declare function createMemoryWebhookStore(initial?: IWebhookTarget): IWebhookStore;
960
+ /**
961
+ * The address in an owner-only file of its own, in an owner-only directory, written atomically. A file
962
+ * that cannot be read as an address means no address: nothing is sent until the person sets one again.
963
+ */
964
+ declare function createFileWebhookStore(directory: string): IWebhookStore;
965
+ /**
966
+ * The address a person typed, as a URL to judge, or a refusal in plain words that never repeats it. A
967
+ * secret-looking value inside the address is expected and is no reason to refuse it.
968
+ */
969
+ declare function parseNotificationAddress(value: unknown): URL;
970
+ /** How one message is written to the address: the headers and the body. */
971
+ declare function webhookMessage(message: IDeliveryMessage, format: TWebhookFormat): {
972
+ readonly headers: Record<string, string>;
973
+ readonly body: string;
974
+ };
975
+ interface INotificationAddressOptions {
976
+ readonly store: IWebhookStore;
977
+ readonly transport: IWebhookTransport;
978
+ }
979
+ declare class NotificationAddress {
980
+ private readonly options;
981
+ /** Takes a message to the address, once. It throws when the address did not take it. */
982
+ readonly sink: IDeliverySink;
983
+ constructor(options: INotificationAddressOptions);
984
+ /** Whether an address is set, which is when its sink is worth offering a message. */
985
+ configured(): Promise<boolean>;
986
+ view(): Promise<INotificationAddressView>;
987
+ /**
988
+ * Keep the address the person gave, in place of any earlier one. `format` is `plain` when left out. It
989
+ * is refused whole, in words that never repeat the address, when it is not an `https` address without
990
+ * a user name or when the outbound-request policy does not allow its destination.
991
+ */
992
+ set(change: unknown): Promise<INotificationAddressView>;
993
+ /** Forget the address: nothing is sent to it again. */
994
+ clear(): Promise<INotificationAddressView>;
995
+ /** Send the fixed test message to the address alone, and say in words that name no address if it did not take it. */
996
+ test(): Promise<void>;
997
+ private send;
998
+ }
999
+ //#endregion
1000
+ //#region src/personal/delivery/question-delivery.d.ts
1001
+ interface IQuestionDeliveryOptions {
1002
+ /** The person's limits; none stored means the defaults. */
1003
+ readonly settings: IDeliveryStore<IDeliverySettings>;
1004
+ readonly state: IDeliveryStore<IDeliveryState>;
1005
+ /**
1006
+ * Where the person is told; a message goes to every sink. A function is asked again for each message,
1007
+ * so a sink that exists only while the person has set it up is there for exactly that long.
1008
+ */
1009
+ readonly sinks: readonly IDeliverySink[] | (() => Promise<readonly IDeliverySink[]>);
1010
+ /** Where a held question is looked up again, to see whether it still waits for an answer. */
1011
+ readonly feed: IDeliveryFeed;
1012
+ /** The time of the machine running the agent; local day and local clock are read from it. */
1013
+ readonly now?: () => Date;
1014
+ /** How long a sink may take before its attempt is given up. */
1015
+ readonly sinkTimeoutMs?: number;
1016
+ }
1017
+ declare class QuestionDelivery {
1018
+ private readonly options;
1019
+ private readonly now;
1020
+ private readonly sinkTimeoutMs;
1021
+ /** Decisions, pushes and digests go one at a time, so two questions cannot both pass the same limit. */
1022
+ private readonly deliveries;
1023
+ private readonly changes;
1024
+ constructor(options: IQuestionDeliveryOptions);
1025
+ private limits;
1026
+ /** The counters for the local day of `at`: a new day starts the count over and keeps what is held. */
1027
+ private load;
1028
+ private attempt;
1029
+ private sinks;
1030
+ /** Send to every sink, once; how many took it. */
1031
+ private send;
1032
+ /** The held questions that still wait for an answer; answered, withdrawn and vanished ones drop out. */
1033
+ private stillOpen;
1034
+ /**
1035
+ * A question was asked. It is pushed now, held for the digest or left alone as the person's limits
1036
+ * say; a push counts toward today's limit only when a sink took it.
1037
+ */
1038
+ onAsked(event: ICaseAskedEvent): Promise<void>;
1039
+ /**
1040
+ * Called every minute and once at start. Sends the day's one digest when its time has come, outside
1041
+ * quiet hours, and some held question still waits for an answer; then forgets what was held and
1042
+ * records the day, so a digest is attempted once a day.
1043
+ */
1044
+ tick(): Promise<void>;
1045
+ /** The person's limits, how many pushes are used today, and how many questions wait for the digest. */
1046
+ status(): Promise<IDeliveryStatus>;
1047
+ /**
1048
+ * Change the person's limits: only what the change names, refused whole when any part is not valid.
1049
+ * Only the person's own request reaches this; no tool does.
1050
+ */
1051
+ updateSettings(change: unknown): Promise<IDeliverySettings>;
1052
+ /** Resolves when everything started so far has finished. */
1053
+ idle(): Promise<void>;
1054
+ }
1055
+ //#endregion
1056
+ //#region src/personal/delivery/stores.d.ts
1057
+ declare function createMemoryDeliveryStore<T>(initial?: T): IDeliveryStore<T>;
1058
+ declare function createFileDeliveryStores(directory: string): {
1059
+ readonly settings: IDeliveryStore<IDeliverySettings>;
1060
+ readonly state: IDeliveryStore<IDeliveryState>;
1061
+ };
1062
+ //#endregion
418
1063
  //#region src/personal/goals/file-store.d.ts
419
1064
  declare function createFileGoalStore(directory: string): IGoalStore;
420
1065
  //#endregion
@@ -430,7 +1075,10 @@ declare const GOAL_TOOL_NAMES: {
430
1075
  declare function renderGoal(goal: IGoal): string;
431
1076
  declare function createGoalTools(book: GoalBook): FunctionTool[];
432
1077
  declare const GOAL_INSTRUCTIONS: string;
433
- /** What a goal run's session is told, on top of the agent's usual instructions. */
1078
+ /**
1079
+ * What a goal run's session is told, on top of the agent's usual instructions. A goal on a case is not
1080
+ * named: its title is the case's, which the agent wrote from content other people wrote.
1081
+ */
434
1082
  declare function goalRunInstructions(goal: IGoal): string;
435
1083
  //#endregion
436
1084
  //#region src/personal/ideas/ideas.d.ts
@@ -677,6 +1325,12 @@ declare class SpaceBook {
677
1325
  /** What a connector is for. A tag the person and the agent read, not a code path. */
678
1326
  type TConnectorKind = 'mail' | 'calendar' | 'files' | 'chat' | 'notes' | 'other';
679
1327
  declare const CONNECTOR_KINDS: readonly TConnectorKind[];
1328
+ /**
1329
+ * How a service asks the person to sign in: `oauth` (a sign-in in their browser, the default), `token`
1330
+ * (a token they type once) or `none` (the service needs no sign-in).
1331
+ */
1332
+ type TConnectorAuth = 'oauth' | 'token' | 'none';
1333
+ declare const CONNECTOR_AUTHS: readonly TConnectorAuth[];
680
1334
  /** The person's own decision about one tool, over what the service claims about it. */
681
1335
  type TToolDecision = 'read' | 'write' | 'blocked';
682
1336
  /** What a tool is treated as: reading is allowed, writing is held for the person, blocked is never called. */
@@ -690,16 +1344,34 @@ interface IConnector {
690
1344
  readonly protocol: string;
691
1345
  /** Where the service is reached: an `https` address that carries no credential. */
692
1346
  readonly endpoint: string;
1347
+ /** How it asks the person to sign in; absent means `oauth`. */
1348
+ readonly auth?: TConnectorAuth;
1349
+ /**
1350
+ * With `token`: the header the token goes in when it is not the standard `Authorization` bearer.
1351
+ * A name only; the token itself is never in a connector.
1352
+ */
1353
+ readonly tokenHeader?: string;
693
1354
  /**
694
1355
  * What the person registered with the service's authorization server when it has no dynamic
695
- * registration. Public values only: a secret never lives in a connector.
1356
+ * registration. Public values only: a secret never lives in a connector (it is typed at sign-in).
696
1357
  */
697
1358
  readonly oauth?: {
698
1359
  readonly clientId?: string;
699
1360
  readonly scopes?: readonly string[];
1361
+ /**
1362
+ * Plain-word parameters the person's sign-in adds to the authorization request, for a service
1363
+ * that needs one to keep a sign-in long-lived. Never a secret.
1364
+ */
1365
+ readonly authorizationParams?: Readonly<Record<string, string>>;
700
1366
  };
701
1367
  /** The person's decisions, by tool name. A tool without one is sorted by what the service claims. */
702
1368
  readonly decisions: Readonly<Record<string, TToolDecision>>;
1369
+ /**
1370
+ * What deserves a question, in the person's own words: one short paragraph a sync run reads before
1371
+ * it looks at the service. Absent means the default for the connector's kind. Only the person sets
1372
+ * it; nothing read from the service ever does.
1373
+ */
1374
+ readonly attention?: string;
703
1375
  readonly createdAt: string;
704
1376
  readonly updatedAt: string;
705
1377
  }
@@ -741,7 +1413,19 @@ interface IConnectorStatus {
741
1413
  }
742
1414
  /** Where the person's browser reaches this agent; the consent returns there. */
743
1415
  interface ISignInContext {
744
- readonly origin: string;
1416
+ /** Where the person's browser reaches this agent; an `oauth` sign-in needs it, the others do not. */
1417
+ readonly origin?: string;
1418
+ /**
1419
+ * The token the person typed for a `token` connector. Held until it is checked and then only in
1420
+ * the owner-only credential directory: never in a connector, an answer or a log.
1421
+ */
1422
+ readonly token?: string;
1423
+ /**
1424
+ * The client secret the person typed for this sign-in, for a service that gives its pre-registered
1425
+ * client one. It is held only until the sign-in ends and then only with the credential the
1426
+ * protocol keeps owner-only: never in a connector, an answer or a log.
1427
+ */
1428
+ readonly clientSecret?: string;
745
1429
  }
746
1430
  type TRevocation = 'revoked' | 'partial' | 'unsupported' | 'failed' | 'not-attempted';
747
1431
  interface IDisconnectOutcome {
@@ -754,12 +1438,21 @@ interface IConnectorCallResult {
754
1438
  readonly text: string;
755
1439
  readonly isError: boolean;
756
1440
  }
1441
+ interface IConnectorDispatchRequest {
1442
+ readonly tool: string;
1443
+ readonly argumentsJson: string;
1444
+ }
1445
+ type TConnectorDispatchAdmission = (dispatch: () => Promise<unknown>, request: IConnectorDispatchRequest) => Promise<{
1446
+ readonly response: Promise<unknown>;
1447
+ }>;
757
1448
  /**
758
1449
  * One protocol's way to reach a service. The composition root supplies it, because reaching a
759
1450
  * service needs a host (network, files, a browser sign-in), and the pack stays neutral.
760
1451
  */
761
1452
  interface IConnectorProtocol {
762
1453
  readonly id: string;
1454
+ /** Guarded calls can be admitted at the final external handoff. */
1455
+ readonly admitsToolDispatch?: true;
763
1456
  status(connector: IConnector): Promise<IConnectorStatus>;
764
1457
  /**
765
1458
  * Start the person's sign-in. Returns at once with where their browser goes; the sign-in finishes
@@ -771,6 +1464,7 @@ interface IConnectorProtocol {
771
1464
  tools(connector: IConnector): Promise<readonly IConnectorToolInfo[]>;
772
1465
  call(connector: IConnector, tool: string, args: Readonly<Record<string, unknown>>, options?: {
773
1466
  readonly signal?: AbortSignal;
1467
+ readonly admitDispatch?: TConnectorDispatchAdmission;
774
1468
  }): Promise<IConnectorCallResult>;
775
1469
  /** Let go of what is held for a connector that is being removed. */
776
1470
  forget(connector: IConnector): Promise<void>;
@@ -795,29 +1489,74 @@ interface ICreateConnectorInput {
795
1489
  readonly kind: TConnectorKind;
796
1490
  readonly protocol: string;
797
1491
  readonly endpoint: string;
1492
+ readonly auth?: TConnectorAuth;
1493
+ readonly tokenHeader?: string;
798
1494
  readonly oauth?: {
799
1495
  readonly clientId?: string;
800
1496
  readonly scopes?: readonly string[];
1497
+ readonly authorizationParams?: Readonly<Record<string, string>>;
801
1498
  };
802
1499
  }
803
1500
  declare class ConnectorBook {
804
1501
  private readonly store;
805
1502
  private readonly now;
806
- private sequence;
807
1503
  constructor(options: {
808
1504
  readonly store: IConnectorStore;
809
1505
  readonly now?: () => Date;
810
1506
  });
811
1507
  create(input: ICreateConnectorInput): Promise<IConnector>;
812
- private checkOAuth;
813
1508
  list(): Promise<readonly IConnector[]>;
814
1509
  get(id: string): Promise<IConnector | undefined>;
815
1510
  existing(id: string): Promise<IConnector>;
816
1511
  /** Record the person's decision about one tool, or clear it with `undefined`. */
817
1512
  decide(id: string, tool: string, decision: TToolDecision | undefined): Promise<IConnector>;
1513
+ /** Record what the person wants to be asked about, in their own words; empty text clears it. */
1514
+ setAttention(id: string, text: string): Promise<IConnector>;
818
1515
  remove(id: string): Promise<void>;
819
1516
  }
820
1517
  //#endregion
1518
+ //#region src/personal/connectors/attention.d.ts
1519
+ /** The longest attention text kept: one short paragraph. */
1520
+ declare const ATTENTION_MAX_CHARACTERS = 600;
1521
+ /** What a connector of this kind asks about until the person words it themselves. */
1522
+ declare function defaultAttention(kind: TConnectorKind): string;
1523
+ /**
1524
+ * The words a sync run is given: the person's own text, or the default for the connector's kind. A
1525
+ * stored text that cannot be used as written (a hand-edited or damaged file) is normalised the way a
1526
+ * saved one is, and an unusable one falls back to the default rather than guessing at it.
1527
+ */
1528
+ declare function effectiveAttention(connector: IConnector): string;
1529
+ //#endregion
1530
+ //#region src/personal/connectors/catalog.d.ts
1531
+ interface IConnectorCatalogEntry {
1532
+ readonly title: string;
1533
+ readonly endpoint: string;
1534
+ readonly kind: TConnectorKind;
1535
+ /** How the service is expected to be signed in to; the person can change it before adding. */
1536
+ readonly auth: TConnectorAuth;
1537
+ readonly tokenHeader?: string;
1538
+ /**
1539
+ * A client the owner registered with the service for this agent, so a person need not register one:
1540
+ * only the owner's file can carry it. The client's secret, if it has one, is never in a suggestion;
1541
+ * the person types it at sign-in.
1542
+ */
1543
+ readonly oauth?: {
1544
+ readonly clientId?: string;
1545
+ readonly scopes?: readonly string[];
1546
+ readonly authorizationParams?: Readonly<Record<string, string>>;
1547
+ };
1548
+ readonly description?: string;
1549
+ /** Where the suggestion came from, as a word the page shows. */
1550
+ readonly source: string;
1551
+ }
1552
+ /**
1553
+ * A catalog entry from one raw record, or `undefined` when the record is not a suggestion the book
1554
+ * would accept (a missing or unusable address, an unknown sign-in way, a header the connection owns).
1555
+ */
1556
+ declare function catalogEntryOf(raw: unknown, source: string): IConnectorCatalogEntry | undefined;
1557
+ /** The services of one page of a registry's answer that can be added here, one entry per address. */
1558
+ declare function catalogEntriesFromRegistry(page: unknown): IConnectorCatalogEntry[];
1559
+ //#endregion
821
1560
  //#region src/personal/connectors/registry.d.ts
822
1561
  interface IConnectorToolView extends IConnectorToolInfo {
823
1562
  /** What the tool is treated as. */
@@ -845,6 +1584,8 @@ interface IConnectorRegistryOptions {
845
1584
  */
846
1585
  declare function classifyTool(connector: IConnector, tool: IConnectorToolInfo): TToolAccess;
847
1586
  declare class ConnectorRegistry {
1587
+ /** This registry forwards guarded actions only to protocols that admit dispatch. */
1588
+ readonly forwardsDispatchAdmission: true;
848
1589
  private readonly book;
849
1590
  private readonly protocols;
850
1591
  private readonly cacheMs;
@@ -858,6 +1599,8 @@ declare class ConnectorRegistry {
858
1599
  view(id: string, options?: {
859
1600
  readonly refresh?: boolean;
860
1601
  }): Promise<IConnectorView>;
1602
+ /** Read the local connection state without discovering tools from the service. */
1603
+ status(id: string): Promise<IConnectorStatus>;
861
1604
  list(): Promise<readonly IConnectorView[]>;
862
1605
  /** Start the person's sign-in; the answer says where their browser goes. */
863
1606
  signIn(id: string, context: ISignInContext): Promise<IConnectorStatus>;
@@ -882,7 +1625,7 @@ declare class ConnectorRegistry {
882
1625
  /** Call a tool that only reads. A tool that writes is refused here, whatever the caller says it is. */
883
1626
  read(id: string, tool: string, args: Readonly<Record<string, unknown>>, signal?: AbortSignal): Promise<IConnectorCallResult>;
884
1627
  /** Call a tool that writes or sends. The person's approval is the caller's gate; a read tool is refused. */
885
- act(id: string, tool: string, args: Readonly<Record<string, unknown>>, signal?: AbortSignal): Promise<IConnectorCallResult>;
1628
+ act(id: string, tool: string, args: Readonly<Record<string, unknown>>, signal?: AbortSignal, admitDispatch?: TConnectorDispatchAdmission): Promise<IConnectorCallResult>;
886
1629
  close(): Promise<void>;
887
1630
  }
888
1631
  //#endregion
@@ -893,6 +1636,11 @@ declare const CONNECTOR_TOOL_NAMES: {
893
1636
  readonly act: "ConnectorAct";
894
1637
  readonly keep: "ConnectorKeep";
895
1638
  };
1639
+ /**
1640
+ * The arguments of a remote tool arrive as JSON text: a tool's own input is whatever its service
1641
+ * declared, and the schema a model is offered carries only what every provider can enforce.
1642
+ */
1643
+ declare function parseConnectorArguments(text: string | undefined): Record<string, unknown>;
896
1644
  declare function createConnectorTools(registry: ConnectorRegistry): FunctionTool[];
897
1645
  declare const CONNECTOR_INSTRUCTIONS: string;
898
1646
  //#endregion
@@ -922,14 +1670,19 @@ declare const SYNC_MIN_MINUTES = 15;
922
1670
  declare const SYNC_MAX_MINUTES: number;
923
1671
  /**
924
1672
  * The only tools a sync run has. Content from the service is written by others, so a run can read it,
925
- * look in the library and add what it finds, and nothing else: it cannot change the service, reach the
926
- * web or the files, drive the browser, rewrite what the person said or set up goals. It is a list of
1673
+ * look in the library, add what it finds and keep a case on what the person should be asked, and nothing
1674
+ * else: it cannot change the service, reach the web or the files, drive the browser, rewrite what the
1675
+ * person said or set up goals. The case tools touch only the agent's own record and the feed. It is a list of
927
1676
  * what is allowed, not of what is withheld: a tool added later is then not offered until it is named.
928
1677
  */
929
1678
  declare function syncRunTools(): string[];
930
1679
  /** What a sync run is asked, as the goal's own text: short, and shown to the person with the goal. */
931
1680
  declare function syncGoalPrompt(connector: IConnector): string;
932
- /** What a sync run is told about how to work, for this run: the connector and where to start. */
1681
+ /**
1682
+ * What a sync run is told about how to work, for this run: the connector, where to start, and the
1683
+ * person's own words about what deserves a question. Those words come before the rules for handling
1684
+ * what is read, and they decide only what the run asks about: they add no tool and no permission.
1685
+ */
933
1686
  declare function syncRunInstructions(connector: IConnector, since: string | undefined): string;
934
1687
  interface IConnectorSyncStatus {
935
1688
  readonly goalId: string;
@@ -954,5 +1707,5 @@ declare class ConnectorSync {
954
1707
  disable(connectorId: string): Promise<boolean>;
955
1708
  }
956
1709
  //#endregion
957
- export { BROWSER_INSTRUCTIONS, BROWSER_TOOL_NAMES, BrowserNavigationRefusedError, BrowserUnavailableError, CONNECTOR_INSTRUCTIONS, CONNECTOR_KINDS, CONNECTOR_TOOL_NAMES, ConnectorBook, ConnectorRefusedError, ConnectorRegistry, ConnectorSync, GOAL_INSTRUCTIONS, GOAL_TOOL_NAMES, GoalBook, GoalRefusedError, type IBrowserActionResult, type IBrowserMark, type IBrowserPort, type IBrowserSnapshot, type IBrowserView, type IChannelAdapter, type IChannelApprovalAnswer, type IChannelApprovalRequest, type IChannelBinding, type IChannelCapabilities, type IChannelHandler, type IChannelHub, type IChannelHubOptions, type IChannelMessage, type IClaim, type IClaimSource, type IConnector, type IConnectorCallResult, type IConnectorProtocol, type IConnectorRegistryOptions, type IConnectorStatus, type IConnectorStore, type IConnectorSyncStatus, type IConnectorToolHints, type IConnectorToolInfo, type IConnectorToolView, type IConnectorView, type ICreateConnectorInput, type ICreateGoalInput, IDEA_INSTRUCTIONS, IDEA_TOOL_NAMES, type IDisconnectOutcome, type IFeedItem, type IFixtureChannel, type IGoal, type IGoalAction, type IGoalBookOptions, type IGoalRun, type IGoalStore, type IHeldSubmission, type IIdea, type IIdeaBookOptions, type IIdeaStore, type IKnowledgeStore, type IKnowledgeWikiOptions, type ILintReport, type IRememberInput, type IRememberResult, type ISearchHit, type ISignInContext, type ISpace, type ISpacePage, type ISpaceStore, type IWikiLogEntry, type IWikiPage, IdeaBook, IdeaRefusedError, KnowledgeWiki, PAGE_KINDS, SYNC_MAX_MINUTES, SYNC_MIN_MINUTES, SensitiveContentRefusedError, SpaceBook, SpaceRefusedError, type TApprovalState, type TChannelApprovalAnswer, type TChannelTurn, type TClaimOrigin, type TConnectorKind, type TConnectorState, type TFeedKind, type TGoalRunOutcome, type TGoalStatus, type TIdeaOrigin, type TIdeaStatus, type TPageKind, type TRevocation, type TToolAccess, type TToolDecision, type TWikiLogAction, WIKI_INSTRUCTIONS, WIKI_TOOL_NAMES, classifyTool, connectorReference, countPulled, createBrowserTools, createChannelHub, createConnectorKeepTool, createConnectorTools, createFileConnectorStore, createFileGoalStore, createFileIdeaStore, createFileKnowledgeStore, createFileSpaceStore, createFixtureChannel, createGoalTools, createIdeaTools, createMemoryConnectorStore, createMemoryGoalStore, createMemoryIdeaStore, createMemoryKnowledgeStore, createMemorySpaceStore, createWikiTools, forgetPulled, goalRunInstructions, originOfConnector, pageIdFor, renderGoal, renderPageForModel, renderPageMarkdown, renderView, splitForChannel, syncGoalPrompt, syncRunInstructions, syncRunTools };
1710
+ export { ATTENTION_MAX_CHARACTERS, BROWSER_INSTRUCTIONS, BROWSER_LISTENING_MS, BROWSER_OUTBOX_CAPACITY, BROWSER_TOOL_NAMES, BrowserNavigationRefusedError, BrowserOutbox, BrowserUnavailableError, CASE_INSTRUCTIONS, CASE_TOOL_NAMES, CASE_URGENCIES, CONNECTOR_AUTHS, CONNECTOR_INSTRUCTIONS, CONNECTOR_KINDS, CONNECTOR_TOOL_NAMES, CaseBook, CaseRefusedError, ConnectorBook, ConnectorRefusedError, ConnectorRegistry, ConnectorSync, DAILY_LIMIT_MAX, DEFAULT_DELIVERY_SETTINGS, DeliveryRefusedError, GOAL_INSTRUCTIONS, GOAL_TOOL_NAMES, GoalBook, GoalRefusedError, type IAnswerInput, type IAskInput, type IBrowserActionResult, type IBrowserMark, type IBrowserNotification, type IBrowserOutboxOptions, type IBrowserPort, type IBrowserSnapshot, type IBrowserView, type ICase, type ICaseAnswerEvent, type ICaseAskedEvent, type ICaseBookOptions, type ICaseEvent, type ICaseNote, type ICaseOrigin, type ICaseQuestion, type ICaseStore, type IChannelAdapter, type IChannelApprovalAnswer, type IChannelApprovalRequest, type IChannelBinding, type IChannelCapabilities, type IChannelHandler, type IChannelHub, type IChannelHubOptions, type IChannelMessage, type IClaim, type IClaimSource, type IConnector, type IConnectorCallResult, type IConnectorCatalogEntry, type IConnectorDispatchRequest, type IConnectorProtocol, type IConnectorRegistryOptions, type IConnectorStatus, type IConnectorStore, type IConnectorSyncStatus, type IConnectorToolHints, type IConnectorToolInfo, type IConnectorToolView, type IConnectorView, type ICreateConnectorInput, type ICreateGoalInput, IDEA_INSTRUCTIONS, IDEA_TOOL_NAMES, type IDecideDeliveryInput, type IDeliveryFeed, type IDeliveryMessage, type IDeliverySettings, type IDeliverySink, type IDeliveryState, type IDeliveryStatus, type IDeliveryStore, type IDigestSchedule, type IDisconnectOutcome, type IFeedItem, type IFeedQuestion, type IFixtureChannel, type IGoal, type IGoalAction, type IGoalBookOptions, type IGoalRun, type IGoalStore, type IHeldSubmission, type IIdea, type IIdeaBookOptions, type IIdeaStore, type IKnowledgeStore, type IKnowledgeWikiOptions, type ILintReport, type INotificationAddressOptions, type INotificationAddressView, type IOpenCaseInput, type IQuestionAnswer, type IQuestionDeliveryOptions, type IQuietHours, type IRememberInput, type IRememberResult, type ISearchHit, type ISignInContext, type ISpace, type ISpacePage, type ISpaceStore, type IWebhookRequest, type IWebhookStore, type IWebhookTarget, type IWebhookTransport, type IWikiLogEntry, type IWikiPage, IdeaBook, IdeaRefusedError, KnowledgeWiki, NotificationAddress, PAGE_KINDS, QuestionDelivery, SYNC_MAX_MINUTES, SYNC_MIN_MINUTES, SensitiveContentRefusedError, SpaceBook, SpaceRefusedError, type TApprovalState, type TCaseEventKind, type TCaseState, type TCaseUrgency, type TChannelApprovalAnswer, type TChannelTurn, type TClaimOrigin, type TConnectorAuth, type TConnectorDispatchAdmission, type TConnectorKind, type TConnectorState, type TDelivery, type TFeedKind, type TGoalRunOutcome, type TGoalStatus, type TIdeaOrigin, type TIdeaStatus, type TPageKind, type TQuestionState, type TRevocation, type TToolAccess, type TToolDecision, type TWebhookAnswer, type TWebhookFormat, type TWikiLogAction, WEBHOOK_FORMATS, WIKI_INSTRUCTIONS, WIKI_TOOL_NAMES, caseTurnInstructions, caseTurnPrompt, caseTurnTools, catalogEntriesFromRegistry, catalogEntryOf, classifyTool, connectorReference, countPulled, createBrowserTools, createCaseTools, createChannelHub, createConnectorKeepTool, createConnectorTools, createFileCaseStore, createFileConnectorStore, createFileDeliveryStores, createFileGoalStore, createFileIdeaStore, createFileKnowledgeStore, createFileSpaceStore, createFileWebhookStore, createFixtureChannel, createGoalTools, createIdeaTools, createMemoryCaseStore, createMemoryConnectorStore, createMemoryDeliveryStore, createMemoryGoalStore, createMemoryIdeaStore, createMemoryKnowledgeStore, createMemorySpaceStore, createMemoryWebhookStore, createWikiTools, decideDelivery, defaultAttention, effectiveAttention, forgetPulled, goalRunInstructions, originOfConnector, pageIdFor, parseConnectorArguments, parseNotificationAddress, renderGoal, renderPageForModel, renderPageMarkdown, renderView, splitForChannel, syncGoalPrompt, syncRunInstructions, syncRunTools, webhookMessage };
958
1711
  //# sourceMappingURL=index.d.cts.map