@robota-sdk/agent-product 3.5.0 → 3.6.1
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/CHANGELOG.md +33 -0
- package/dist/coding/index.cjs +1 -1
- package/dist/coding/index.js +1 -1
- package/dist/command/index.cjs +1 -1
- package/dist/command/index.d.cts +11 -2
- package/dist/command/index.d.cts.map +1 -1
- package/dist/command/index.d.ts +11 -2
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +1 -1
- package/dist/{command-BEEZrEw-.cjs → command--ag0fdHz.cjs} +64 -64
- package/dist/{command-0nMdpRQZ.js → command-BXOf0yNQ.js} +7 -7
- package/dist/{command-0nMdpRQZ.js.map → command-BXOf0yNQ.js.map} +1 -1
- package/dist/personal/index.cjs +21 -12
- package/dist/personal/index.d.cts +1105 -4
- package/dist/personal/index.d.cts.map +1 -1
- package/dist/personal/index.d.ts +1105 -4
- package/dist/personal/index.d.ts.map +1 -1
- package/dist/personal/index.js +24 -15
- package/dist/personal/index.js.map +1 -1
- package/package.json +4 -4
package/dist/personal/index.d.ts
CHANGED
|
@@ -225,6 +225,13 @@ interface IBrowserActionResult {
|
|
|
225
225
|
/** Present when the action made requests that write; they were held, not sent. */
|
|
226
226
|
readonly held?: readonly IHeldSubmission[];
|
|
227
227
|
}
|
|
228
|
+
/** What the agent's page looks like right now, for a person watching it work. */
|
|
229
|
+
interface IBrowserSnapshot {
|
|
230
|
+
readonly url: string;
|
|
231
|
+
readonly title: string;
|
|
232
|
+
/** A PNG screenshot of the visible page. */
|
|
233
|
+
readonly png: Uint8Array;
|
|
234
|
+
}
|
|
228
235
|
interface IBrowserPort {
|
|
229
236
|
open(url: string): Promise<IBrowserView>;
|
|
230
237
|
view(): Promise<IBrowserView>;
|
|
@@ -238,6 +245,11 @@ interface IBrowserPort {
|
|
|
238
245
|
readonly method: string;
|
|
239
246
|
readonly url: string;
|
|
240
247
|
}): Promise<IBrowserActionResult>;
|
|
248
|
+
/**
|
|
249
|
+
* The current page as a person would see it, or undefined when no page is open. Optional: a host
|
|
250
|
+
* that cannot take a picture leaves it out, and only watching is lost.
|
|
251
|
+
*/
|
|
252
|
+
snapshot?(): Promise<IBrowserSnapshot | undefined>;
|
|
241
253
|
close(): Promise<void>;
|
|
242
254
|
}
|
|
243
255
|
declare class BrowserUnavailableError extends Error {
|
|
@@ -279,6 +291,10 @@ interface IGoal {
|
|
|
279
291
|
readonly everyMinutes?: number;
|
|
280
292
|
/** Change nothing while running: the agent may only look, and anything else is refused. */
|
|
281
293
|
readonly readOnly: boolean;
|
|
294
|
+
/** The connector this goal keeps in sync, when it is one: a person's own goals have none. */
|
|
295
|
+
readonly connectorId?: string;
|
|
296
|
+
/** The case this goal gives a turn on, when it is one: found by this id, and run again for each answer. */
|
|
297
|
+
readonly caseId?: string;
|
|
282
298
|
readonly status: TGoalStatus;
|
|
283
299
|
/** When the goal is next due (ISO 8601); absent when it is not scheduled. */
|
|
284
300
|
readonly nextRunAt?: string;
|
|
@@ -305,8 +321,31 @@ interface IGoalRun {
|
|
|
305
321
|
readonly report?: string;
|
|
306
322
|
readonly actions: readonly IGoalAction[];
|
|
307
323
|
}
|
|
308
|
-
type TFeedKind = 'report' | 'approval' | 'notice';
|
|
324
|
+
type TFeedKind = 'report' | 'approval' | 'notice' | 'question';
|
|
309
325
|
type TApprovalState = 'pending' | 'approved' | 'denied' | 'expired';
|
|
326
|
+
/** A question is open until the person answers it, or withdrawn when its case closes first. */
|
|
327
|
+
type TQuestionState = 'open' | 'answered' | 'withdrawn';
|
|
328
|
+
/** What the person answered: one of the offered choices, or a reply in their own words. */
|
|
329
|
+
interface IQuestionAnswer {
|
|
330
|
+
readonly choice?: string;
|
|
331
|
+
readonly reply?: string;
|
|
332
|
+
readonly at: string;
|
|
333
|
+
}
|
|
334
|
+
/** The question the agent asks from a case, and where it stands. Never approved, only answered. */
|
|
335
|
+
interface IFeedQuestion {
|
|
336
|
+
readonly caseId: string;
|
|
337
|
+
readonly text: string;
|
|
338
|
+
readonly options: readonly string[];
|
|
339
|
+
readonly allowsReply: boolean;
|
|
340
|
+
readonly state: TQuestionState;
|
|
341
|
+
readonly answer?: IQuestionAnswer;
|
|
342
|
+
/**
|
|
343
|
+
* How the case closed, when it closed right after this answer: shown under the answer so a close the
|
|
344
|
+
* person would want to know about is not left in the case's thread alone. Written by the agent from
|
|
345
|
+
* content other people wrote, so a host shows it as plain text.
|
|
346
|
+
*/
|
|
347
|
+
readonly resolution?: string;
|
|
348
|
+
}
|
|
310
349
|
interface IFeedItem {
|
|
311
350
|
readonly id: string;
|
|
312
351
|
readonly at: string;
|
|
@@ -321,6 +360,8 @@ interface IFeedItem {
|
|
|
321
360
|
readonly detail: string;
|
|
322
361
|
readonly state: TApprovalState;
|
|
323
362
|
};
|
|
363
|
+
/** Present on a question: what the agent asks the person about one of its cases. */
|
|
364
|
+
readonly question?: IFeedQuestion;
|
|
324
365
|
readonly dismissed: boolean;
|
|
325
366
|
}
|
|
326
367
|
/** Where goals, their runs and the feed live; a host supplies one per principal. */
|
|
@@ -348,6 +389,8 @@ interface ICreateGoalInput {
|
|
|
348
389
|
readonly instructions: string;
|
|
349
390
|
readonly everyMinutes?: number;
|
|
350
391
|
readonly readOnly?: boolean;
|
|
392
|
+
readonly connectorId?: string;
|
|
393
|
+
readonly caseId?: string;
|
|
351
394
|
}
|
|
352
395
|
declare class GoalRefusedError extends Error {
|
|
353
396
|
constructor(reason: string);
|
|
@@ -368,14 +411,33 @@ declare class GoalBook {
|
|
|
368
411
|
/** Goals due now: active and scheduled at or before this moment. */
|
|
369
412
|
due(): Promise<readonly IGoal[]>;
|
|
370
413
|
pause(id: string): Promise<IGoal>;
|
|
414
|
+
/**
|
|
415
|
+
* Change how often a goal repeats. A run in progress keeps going and the next one follows the new
|
|
416
|
+
* interval; otherwise the goal is active again and due that long after its last run (at once if it
|
|
417
|
+
* never ran or that moment has passed).
|
|
418
|
+
*/
|
|
419
|
+
reschedule(id: string, everyMinutes: number): Promise<IGoal>;
|
|
371
420
|
/** Make a paused, finished or failed goal due now. */
|
|
372
421
|
resume(id: string): Promise<IGoal>;
|
|
422
|
+
/**
|
|
423
|
+
* Make a goal that has finished due now again, as a one-shot goal's next turn: a case's goal runs once
|
|
424
|
+
* for each answer. A goal still running or waiting is refused, since a second run would start before
|
|
425
|
+
* the first ended, and so is a paused one, which the person stopped; `resume` is for them. The interval
|
|
426
|
+
* is untouched, so a scheduled goal follows its own schedule again once the extra run ends.
|
|
427
|
+
*/
|
|
428
|
+
runAgain(id: string): Promise<IGoal>;
|
|
373
429
|
remove(id: string): Promise<void>;
|
|
374
430
|
startRun(goalId: string): Promise<IGoalRun>;
|
|
375
431
|
recordAction(run: IGoalRun, action: Omit<IGoalAction, 'at'>): Promise<IGoalRun>;
|
|
376
432
|
setWaiting(goalId: string, waiting: boolean): Promise<void>;
|
|
377
433
|
/** End a run, schedule the next one or close the goal, and report to the feed. */
|
|
378
|
-
|
|
434
|
+
/**
|
|
435
|
+
* End a run. A `quiet` run that went well is kept in the goal's history but is not posted to the
|
|
436
|
+
* feed, so a goal that mostly finds nothing does not fill it; a run that did not go well is posted.
|
|
437
|
+
*/
|
|
438
|
+
finishRun(run: IGoalRun, outcome: TGoalRunOutcome, report: string, options?: {
|
|
439
|
+
readonly quiet?: boolean;
|
|
440
|
+
}): Promise<IGoalRun>;
|
|
379
441
|
/**
|
|
380
442
|
* After the host restarts, nothing is running: a goal it was running is due again, and an approval
|
|
381
443
|
* it was waiting on can no longer be answered.
|
|
@@ -385,9 +447,499 @@ declare class GoalBook {
|
|
|
385
447
|
feed(limit?: number): Promise<readonly IFeedItem[]>;
|
|
386
448
|
feedItem(id: string): Promise<IFeedItem | undefined>;
|
|
387
449
|
setApproval(id: string, state: TApprovalState): Promise<IFeedItem>;
|
|
450
|
+
/** Record the person's answer to a question; a question is answered once. */
|
|
451
|
+
answerQuestion(id: string, answer: Omit<IQuestionAnswer, 'at'>): Promise<IFeedItem>;
|
|
452
|
+
/** Show how the case closed under the person's answer; only an answered question carries one. */
|
|
453
|
+
resolveQuestion(id: string, resolution: string): Promise<IFeedItem>;
|
|
454
|
+
/** A question whose case closed before the person answered it can no longer be answered. */
|
|
455
|
+
withdrawQuestion(id: string): Promise<IFeedItem>;
|
|
388
456
|
dismiss(id: string): Promise<void>;
|
|
389
457
|
}
|
|
390
458
|
//#endregion
|
|
459
|
+
//#region src/personal/cases/types.d.ts
|
|
460
|
+
/**
|
|
461
|
+
* Cases: a thread of thought the agent opens from something it noticed, asks the person about, and
|
|
462
|
+
* keeps until it is settled. A case is not a chat and not a goal: it is the agent's own record of one
|
|
463
|
+
* matter (what it saw, what it noted, the one question it is waiting on, and what happened), kept
|
|
464
|
+
* beside the goals and the feed the question is shown in.
|
|
465
|
+
*/
|
|
466
|
+
type TCaseState = 'open' | 'closed';
|
|
467
|
+
type TCaseEventKind = 'observed' | 'noted' | 'asked' | 'answered' | 'closed';
|
|
468
|
+
/**
|
|
469
|
+
* How soon the agent suggests a question be put to the person: `now` for what needs them soon, `digest`
|
|
470
|
+
* for what can wait for a daily summary, `feed` for the rest. It is only a suggestion: what actually
|
|
471
|
+
* reaches the person is decided by their own delivery limits.
|
|
472
|
+
*/
|
|
473
|
+
type TCaseUrgency = 'now' | 'digest' | 'feed';
|
|
474
|
+
/** Where a case came from: the service that showed it and the agent's own stable reference to the item. */
|
|
475
|
+
interface ICaseOrigin {
|
|
476
|
+
readonly connectorId?: string;
|
|
477
|
+
/** The same reference for the same item every time, so one source never opens two cases. */
|
|
478
|
+
readonly source: string;
|
|
479
|
+
}
|
|
480
|
+
interface ICaseNote {
|
|
481
|
+
readonly at: string;
|
|
482
|
+
readonly text: string;
|
|
483
|
+
}
|
|
484
|
+
/** The question a case is waiting on; at most one at a time. */
|
|
485
|
+
interface ICaseQuestion {
|
|
486
|
+
readonly text: string;
|
|
487
|
+
/** The answers the person may pick; empty when only a reply is wanted. */
|
|
488
|
+
readonly options: readonly string[];
|
|
489
|
+
readonly allowsReply: boolean;
|
|
490
|
+
readonly askedAt: string;
|
|
491
|
+
/** The feed item that shows the question to the person. */
|
|
492
|
+
readonly feedItemId: string;
|
|
493
|
+
/** The agent's suggestion of how urgent the question is; absent in a case written before it existed, which reads as `feed`. */
|
|
494
|
+
readonly urgency?: TCaseUrgency;
|
|
495
|
+
}
|
|
496
|
+
/** What happened on the case, oldest first. */
|
|
497
|
+
interface ICaseEvent {
|
|
498
|
+
readonly at: string;
|
|
499
|
+
readonly kind: TCaseEventKind;
|
|
500
|
+
readonly text: string;
|
|
501
|
+
}
|
|
502
|
+
interface ICase {
|
|
503
|
+
readonly id: string;
|
|
504
|
+
readonly title: string;
|
|
505
|
+
readonly origin: ICaseOrigin;
|
|
506
|
+
readonly state: TCaseState;
|
|
507
|
+
/** The agent's running notes, oldest first; what a question shows as its evidence. */
|
|
508
|
+
readonly notes: readonly ICaseNote[];
|
|
509
|
+
readonly question?: ICaseQuestion;
|
|
510
|
+
/**
|
|
511
|
+
* The feed item that showed the question the person answered last; it is where the case's resolution
|
|
512
|
+
* is shown if the case closes after that answer. Absent until a question is answered, and in a case
|
|
513
|
+
* written before it existed, where there is nothing to show it on.
|
|
514
|
+
*/
|
|
515
|
+
readonly lastAnsweredFeedItemId?: string;
|
|
516
|
+
readonly history: readonly ICaseEvent[];
|
|
517
|
+
readonly createdAt: string;
|
|
518
|
+
readonly updatedAt: string;
|
|
519
|
+
}
|
|
520
|
+
/** Where cases live; a host supplies one per principal. */
|
|
521
|
+
interface ICaseStore {
|
|
522
|
+
list(): Promise<readonly ICase[]>;
|
|
523
|
+
get(id: string): Promise<ICase | undefined>;
|
|
524
|
+
put(item: ICase): Promise<void>;
|
|
525
|
+
}
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/personal/cases/case-book.d.ts
|
|
528
|
+
declare const CASE_URGENCIES: readonly TCaseUrgency[];
|
|
529
|
+
declare class CaseRefusedError extends Error {
|
|
530
|
+
constructor(reason: string);
|
|
531
|
+
}
|
|
532
|
+
/** What a host is told when a question was asked: the case, the card that shows it, and the urgency suggested. */
|
|
533
|
+
interface ICaseAskedEvent {
|
|
534
|
+
readonly case: ICase;
|
|
535
|
+
readonly item: IFeedItem;
|
|
536
|
+
readonly urgency: TCaseUrgency;
|
|
537
|
+
}
|
|
538
|
+
interface ICaseBookOptions {
|
|
539
|
+
readonly store: ICaseStore;
|
|
540
|
+
/** Where a question is shown to the person, and where their answer is recorded. */
|
|
541
|
+
readonly feed: GoalBook;
|
|
542
|
+
/**
|
|
543
|
+
* Called once a question has been asked and written. It is not waited for and cannot fail the ask: a
|
|
544
|
+
* question is already in the feed when this runs, whatever the host does about telling the person.
|
|
545
|
+
*/
|
|
546
|
+
readonly onAsked?: (event: ICaseAskedEvent) => void | Promise<void>;
|
|
547
|
+
readonly now?: () => Date;
|
|
548
|
+
}
|
|
549
|
+
interface IOpenCaseInput {
|
|
550
|
+
readonly title: string;
|
|
551
|
+
/** What was noticed and why it matters; the case's first note. */
|
|
552
|
+
readonly noticed: string;
|
|
553
|
+
/** The agent's own stable reference to the item, so the same item opens one case. */
|
|
554
|
+
readonly source: string;
|
|
555
|
+
readonly connectorId?: string;
|
|
556
|
+
}
|
|
557
|
+
interface IAskInput {
|
|
558
|
+
readonly question: string;
|
|
559
|
+
readonly options?: readonly string[];
|
|
560
|
+
/** Whether the person may answer in their own words; by default, when there are no choices. */
|
|
561
|
+
readonly allowsReply?: boolean;
|
|
562
|
+
/** How urgent the agent suggests the question is; `feed` when it says nothing. */
|
|
563
|
+
readonly urgency?: string;
|
|
564
|
+
}
|
|
565
|
+
interface IAnswerInput {
|
|
566
|
+
readonly choice?: string;
|
|
567
|
+
readonly reply?: string;
|
|
568
|
+
}
|
|
569
|
+
declare class CaseBook {
|
|
570
|
+
private readonly store;
|
|
571
|
+
private readonly feed;
|
|
572
|
+
private readonly onAsked;
|
|
573
|
+
private readonly now;
|
|
574
|
+
private sequence;
|
|
575
|
+
private tail;
|
|
576
|
+
constructor(options: ICaseBookOptions);
|
|
577
|
+
/** Tell the host a question was asked, without waiting for it and without letting it fail the ask. */
|
|
578
|
+
private announce;
|
|
579
|
+
private stamp;
|
|
580
|
+
/** One write at a time, so two calls in one turn cannot both pass a check the other changes. */
|
|
581
|
+
private exclusive;
|
|
582
|
+
private require;
|
|
583
|
+
private requireOpen;
|
|
584
|
+
/** A card that still looks open although its case moved on becomes a withdrawn one, which can be dismissed. */
|
|
585
|
+
private stale;
|
|
586
|
+
private requireRoom;
|
|
587
|
+
/** Open a case, or return the one this source already opened, open or closed. */
|
|
588
|
+
open(input: IOpenCaseInput): Promise<{
|
|
589
|
+
readonly case: ICase;
|
|
590
|
+
readonly existing: boolean;
|
|
591
|
+
}>;
|
|
592
|
+
note(id: string, text: string): Promise<ICase>;
|
|
593
|
+
/** Ask the person the case's one question; it shows in their feed with the notes as its evidence. */
|
|
594
|
+
ask(id: string, input: IAskInput): Promise<{
|
|
595
|
+
readonly case: ICase;
|
|
596
|
+
readonly item: IFeedItem;
|
|
597
|
+
}>;
|
|
598
|
+
/**
|
|
599
|
+
* Record the person's answer to a question in the feed: one of its choices, or a reply when the
|
|
600
|
+
* question allows one. The case moves on with no question waiting; what to do next is not decided here.
|
|
601
|
+
*/
|
|
602
|
+
answer(feedItemId: string, input: IAnswerInput): Promise<{
|
|
603
|
+
readonly case: ICase;
|
|
604
|
+
readonly item: IFeedItem;
|
|
605
|
+
}>;
|
|
606
|
+
/**
|
|
607
|
+
* Settle a case with a one-line resolution. A question still waiting is withdrawn from the feed; with
|
|
608
|
+
* none waiting, the resolution is shown on the card of the question the person answered last, so a
|
|
609
|
+
* close that matters to them (the agent telling them to go to the service directly, say) is not left
|
|
610
|
+
* in the case's thread alone. The case is written first: if that fails nothing changed and the case
|
|
611
|
+
* still waits on a visible card, and if the withdrawal fails the case is closed and its card is
|
|
612
|
+
* withdrawn when the person next answers it.
|
|
613
|
+
*/
|
|
614
|
+
close(id: string, resolution: string): Promise<ICase>;
|
|
615
|
+
/**
|
|
616
|
+
* The card shows a copy of what the closed case already holds, so a card that cannot take it is left
|
|
617
|
+
* as it is: failing the close here would tell the agent a close that happened had not, and a second
|
|
618
|
+
* close is refused, so nothing could be retried. The resolution stays in the case's thread.
|
|
619
|
+
*/
|
|
620
|
+
private showResolution;
|
|
621
|
+
get(id: string): Promise<ICase | undefined>;
|
|
622
|
+
/** Open cases first, then the ones closed last; each newest first. */
|
|
623
|
+
list(limit?: number): Promise<readonly ICase[]>;
|
|
624
|
+
}
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region src/personal/cases/stores.d.ts
|
|
627
|
+
declare function createMemoryCaseStore(): ICaseStore;
|
|
628
|
+
declare function createFileCaseStore(directory: string): ICaseStore;
|
|
629
|
+
//#endregion
|
|
630
|
+
//#region src/personal/cases/tools.d.ts
|
|
631
|
+
declare const CASE_TOOL_NAMES: {
|
|
632
|
+
readonly open: "CaseOpen";
|
|
633
|
+
readonly note: "CaseNote";
|
|
634
|
+
readonly ask: "CaseAsk";
|
|
635
|
+
readonly close: "CaseClose";
|
|
636
|
+
};
|
|
637
|
+
declare function createCaseTools(book: CaseBook): FunctionTool[];
|
|
638
|
+
declare const CASE_INSTRUCTIONS: string;
|
|
639
|
+
//#endregion
|
|
640
|
+
//#region src/personal/cases/turn.d.ts
|
|
641
|
+
/**
|
|
642
|
+
* The only tools a case turn has: it may look at the connector and the library to check something
|
|
643
|
+
* related, and keep the case (note, ask, close). It cannot change a service, keep a fact, reach the web,
|
|
644
|
+
* the files or the browser, or set up goals. It is a list of what is allowed, not of what is withheld: a
|
|
645
|
+
* tool added later is then not offered until it is named.
|
|
646
|
+
*/
|
|
647
|
+
declare function caseTurnTools(): string[];
|
|
648
|
+
/**
|
|
649
|
+
* What a case turn is asked, as the goal's own text: short, and shown to the person with the goal. It
|
|
650
|
+
* carries no case text, since the title was written by the agent from content other people wrote.
|
|
651
|
+
*/
|
|
652
|
+
declare function caseTurnPrompt(): string;
|
|
653
|
+
/**
|
|
654
|
+
* What a case turn is told about how to work, for this turn: the person's answer and what to do. The
|
|
655
|
+
* title, the question and the notes were written by the agent from content other people wrote, so they
|
|
656
|
+
* come after the label that says so, and the directions come after them; only the case id and the
|
|
657
|
+
* person's own answer stand before it.
|
|
658
|
+
*/
|
|
659
|
+
declare function caseTurnInstructions(found: ICase): string;
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/personal/delivery/types.d.ts
|
|
662
|
+
/** Times are `HH:MM` on a 24-hour clock, in the local time of the machine that runs the agent. */
|
|
663
|
+
interface IQuietHours {
|
|
664
|
+
readonly enabled: boolean;
|
|
665
|
+
readonly from: string;
|
|
666
|
+
readonly to: string;
|
|
667
|
+
}
|
|
668
|
+
interface IDigestSchedule {
|
|
669
|
+
readonly enabled: boolean;
|
|
670
|
+
readonly at: string;
|
|
671
|
+
}
|
|
672
|
+
/** The person's limits. Local time throughout: that of the machine running the agent. */
|
|
673
|
+
interface IDeliverySettings {
|
|
674
|
+
/** How many questions may be pushed immediately in one local day, 0 to 20; 0 pushes none. */
|
|
675
|
+
readonly dailyLimit: number;
|
|
676
|
+
/** While it lasts nothing is pushed immediately; a window may cross midnight. */
|
|
677
|
+
readonly quietHours: IQuietHours;
|
|
678
|
+
/** Whether questions that can wait are gathered into one daily summary, and when it goes out. */
|
|
679
|
+
readonly digest: IDigestSchedule;
|
|
680
|
+
}
|
|
681
|
+
/** What delivery remembers between runs. */
|
|
682
|
+
interface IDeliveryState {
|
|
683
|
+
/** The local day `sent` counts, as `YYYY-MM-DD`. */
|
|
684
|
+
readonly day: string;
|
|
685
|
+
/** How many questions were pushed immediately on `day`. */
|
|
686
|
+
readonly sent: number;
|
|
687
|
+
/** The local day the last digest went out. */
|
|
688
|
+
readonly digestedOn?: string;
|
|
689
|
+
/** Feed items waiting for the next digest. */
|
|
690
|
+
readonly pendingDigest: readonly string[];
|
|
691
|
+
}
|
|
692
|
+
/** What becomes of one question: pushed now, held for the daily summary, or left in the feed. */
|
|
693
|
+
type TDelivery = 'notify' | 'digest' | 'feed';
|
|
694
|
+
interface IDeliveryMessage {
|
|
695
|
+
/** A `test` message is the person's own check that a sink works; it is never a question. */
|
|
696
|
+
readonly kind: 'question' | 'digest' | 'test';
|
|
697
|
+
/** A short plain line that says what the message is about, for a sink that shows a heading. */
|
|
698
|
+
readonly title: string;
|
|
699
|
+
/** Plain text on one or a few lines; a sink adds nothing to it. */
|
|
700
|
+
readonly text: string;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Somewhere a message can be pushed to: the person's connected messengers, an address they gave, a page
|
|
704
|
+
* they have open. A sink that cannot take a message throws, which is how a push is told from one that
|
|
705
|
+
* was not taken.
|
|
706
|
+
*/
|
|
707
|
+
interface IDeliverySink {
|
|
708
|
+
readonly id: string;
|
|
709
|
+
deliver(message: IDeliveryMessage): Promise<void>;
|
|
710
|
+
}
|
|
711
|
+
/** Where one value lives between runs; a host supplies one for each. */
|
|
712
|
+
interface IDeliveryStore<T> {
|
|
713
|
+
/** The stored value, or `undefined` when nothing was stored yet. */
|
|
714
|
+
read(): Promise<T | undefined>;
|
|
715
|
+
write(value: T): Promise<void>;
|
|
716
|
+
}
|
|
717
|
+
/** What the person sees of delivery: their limits, today's pushes against them, and what waits for the digest. */
|
|
718
|
+
interface IDeliveryStatus {
|
|
719
|
+
readonly settings: IDeliverySettings;
|
|
720
|
+
readonly today: {
|
|
721
|
+
readonly sent: number;
|
|
722
|
+
readonly limit: number;
|
|
723
|
+
};
|
|
724
|
+
/** Open questions held for the next digest. */
|
|
725
|
+
readonly waitingInDigest: number;
|
|
726
|
+
}
|
|
727
|
+
/** The feed as delivery needs it: a card, looked up again before a digest names it. */
|
|
728
|
+
interface IDeliveryFeed {
|
|
729
|
+
feedItem(id: string): Promise<IFeedItem | undefined>;
|
|
730
|
+
}
|
|
731
|
+
//#endregion
|
|
732
|
+
//#region src/personal/delivery/policy.d.ts
|
|
733
|
+
declare const DAILY_LIMIT_MAX = 20;
|
|
734
|
+
declare const DEFAULT_DELIVERY_SETTINGS: IDeliverySettings;
|
|
735
|
+
declare class DeliveryRefusedError extends Error {
|
|
736
|
+
constructor(reason: string);
|
|
737
|
+
}
|
|
738
|
+
interface IDecideDeliveryInput {
|
|
739
|
+
readonly urgency: TCaseUrgency;
|
|
740
|
+
readonly now: Date;
|
|
741
|
+
readonly settings: IDeliverySettings;
|
|
742
|
+
/** How many questions were already pushed immediately on the local day of `now`. */
|
|
743
|
+
readonly sentToday: number;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* `feed` stays in the feed. `digest` waits for the daily summary, or stays in the feed when there is
|
|
747
|
+
* none. `now` is pushed unless the person's quiet hours or daily limit say otherwise, and then it is
|
|
748
|
+
* held like a `digest`.
|
|
749
|
+
*/
|
|
750
|
+
declare function decideDelivery(input: IDecideDeliveryInput): TDelivery;
|
|
751
|
+
//#endregion
|
|
752
|
+
//#region src/personal/delivery/browser-outbox.d.ts
|
|
753
|
+
/** How many messages are kept; an older one is dropped for a new one. */
|
|
754
|
+
declare const BROWSER_OUTBOX_CAPACITY = 20;
|
|
755
|
+
/** How long after its last poll a page still counts as open. */
|
|
756
|
+
declare const BROWSER_LISTENING_MS = 90000;
|
|
757
|
+
interface IBrowserNotification {
|
|
758
|
+
/** Counts up from 1 for as long as the agent runs, so a page asks for what came after the last one it saw. */
|
|
759
|
+
readonly id: number;
|
|
760
|
+
readonly at: string;
|
|
761
|
+
readonly kind: IDeliveryMessage['kind'];
|
|
762
|
+
readonly title: string;
|
|
763
|
+
readonly text: string;
|
|
764
|
+
}
|
|
765
|
+
interface IBrowserOutboxOptions {
|
|
766
|
+
/** Milliseconds, on the clock the page's polls are counted by. */
|
|
767
|
+
readonly now?: () => number;
|
|
768
|
+
readonly capacity?: number;
|
|
769
|
+
readonly listeningMs?: number;
|
|
770
|
+
}
|
|
771
|
+
declare class BrowserOutbox implements IDeliverySink {
|
|
772
|
+
readonly id = "browser";
|
|
773
|
+
private readonly now;
|
|
774
|
+
private readonly capacity;
|
|
775
|
+
private readonly listeningMs;
|
|
776
|
+
private messages;
|
|
777
|
+
private latest;
|
|
778
|
+
private polledAt;
|
|
779
|
+
constructor(options?: IBrowserOutboxOptions);
|
|
780
|
+
/** Whether a page has polled lately enough to be open. */
|
|
781
|
+
listening(): boolean;
|
|
782
|
+
/** Keeps the message for the page to fetch, or throws when no page is open to take it. */
|
|
783
|
+
deliver(message: IDeliveryMessage): Promise<void>;
|
|
784
|
+
/**
|
|
785
|
+
* A page asks what came after the last message it saw; that it asked is what shows a page is open.
|
|
786
|
+
* A page with nothing yet asks from now on and gets none; one that remembers a later message than any
|
|
787
|
+
* here, as after a restart, gets everything kept.
|
|
788
|
+
*/
|
|
789
|
+
poll(after?: number): {
|
|
790
|
+
readonly messages: readonly IBrowserNotification[];
|
|
791
|
+
readonly latest: number;
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
//#endregion
|
|
795
|
+
//#region src/personal/delivery/notification-address.d.ts
|
|
796
|
+
declare const WEBHOOK_FORMATS: readonly ["plain", "json"];
|
|
797
|
+
type TWebhookFormat = (typeof WEBHOOK_FORMATS)[number];
|
|
798
|
+
/** The address as kept, and how a message is written to it. */
|
|
799
|
+
interface IWebhookTarget {
|
|
800
|
+
readonly url: string;
|
|
801
|
+
readonly format: TWebhookFormat;
|
|
802
|
+
}
|
|
803
|
+
/** Where the address lives between runs; a host supplies one. Only this module reads it. */
|
|
804
|
+
interface IWebhookStore {
|
|
805
|
+
read(): Promise<IWebhookTarget | undefined>;
|
|
806
|
+
write(value: IWebhookTarget): Promise<void>;
|
|
807
|
+
clear(): Promise<void>;
|
|
808
|
+
}
|
|
809
|
+
interface IWebhookRequest {
|
|
810
|
+
readonly url: string;
|
|
811
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
812
|
+
readonly body: string;
|
|
813
|
+
/** The whole exchange, answer included, is given up after this long. */
|
|
814
|
+
readonly timeoutMs: number;
|
|
815
|
+
}
|
|
816
|
+
/** The status of the answer, or why the destination was not reached; the words name no address. */
|
|
817
|
+
type TWebhookAnswer = {
|
|
818
|
+
readonly status: number;
|
|
819
|
+
} | {
|
|
820
|
+
readonly refused: string;
|
|
821
|
+
};
|
|
822
|
+
/** What the host lends for the network: its outbound-request policy and its way to send. */
|
|
823
|
+
interface IWebhookTransport {
|
|
824
|
+
/** Why this destination may not be reached, or `undefined` when it may. Words name no address. */
|
|
825
|
+
admit(url: URL): Promise<string | undefined>;
|
|
826
|
+
/**
|
|
827
|
+
* One request to the address, which is judged by the same policy again, with no redirect followed. It
|
|
828
|
+
* throws when the destination cannot be reached or does not answer in time.
|
|
829
|
+
*/
|
|
830
|
+
post(request: IWebhookRequest): Promise<TWebhookAnswer>;
|
|
831
|
+
}
|
|
832
|
+
/** What the person is told about the address: never the address itself. */
|
|
833
|
+
interface INotificationAddressView {
|
|
834
|
+
readonly configured: boolean;
|
|
835
|
+
/** The host (and port) the notifications go to; present only when one is set. */
|
|
836
|
+
readonly host?: string;
|
|
837
|
+
readonly format: TWebhookFormat;
|
|
838
|
+
}
|
|
839
|
+
declare function createMemoryWebhookStore(initial?: IWebhookTarget): IWebhookStore;
|
|
840
|
+
/**
|
|
841
|
+
* The address in an owner-only file of its own, in an owner-only directory, written atomically. A file
|
|
842
|
+
* that cannot be read as an address means no address: nothing is sent until the person sets one again.
|
|
843
|
+
*/
|
|
844
|
+
declare function createFileWebhookStore(directory: string): IWebhookStore;
|
|
845
|
+
/**
|
|
846
|
+
* The address a person typed, as a URL to judge, or a refusal in plain words that never repeats it. A
|
|
847
|
+
* secret-looking value inside the address is expected and is no reason to refuse it.
|
|
848
|
+
*/
|
|
849
|
+
declare function parseNotificationAddress(value: unknown): URL;
|
|
850
|
+
/** How one message is written to the address: the headers and the body. */
|
|
851
|
+
declare function webhookMessage(message: IDeliveryMessage, format: TWebhookFormat): {
|
|
852
|
+
readonly headers: Record<string, string>;
|
|
853
|
+
readonly body: string;
|
|
854
|
+
};
|
|
855
|
+
interface INotificationAddressOptions {
|
|
856
|
+
readonly store: IWebhookStore;
|
|
857
|
+
readonly transport: IWebhookTransport;
|
|
858
|
+
}
|
|
859
|
+
declare class NotificationAddress {
|
|
860
|
+
private readonly options;
|
|
861
|
+
/** Takes a message to the address, once. It throws when the address did not take it. */
|
|
862
|
+
readonly sink: IDeliverySink;
|
|
863
|
+
constructor(options: INotificationAddressOptions);
|
|
864
|
+
/** Whether an address is set, which is when its sink is worth offering a message. */
|
|
865
|
+
configured(): Promise<boolean>;
|
|
866
|
+
view(): Promise<INotificationAddressView>;
|
|
867
|
+
/**
|
|
868
|
+
* Keep the address the person gave, in place of any earlier one. `format` is `plain` when left out. It
|
|
869
|
+
* is refused whole, in words that never repeat the address, when it is not an `https` address without
|
|
870
|
+
* a user name or when the outbound-request policy does not allow its destination.
|
|
871
|
+
*/
|
|
872
|
+
set(change: unknown): Promise<INotificationAddressView>;
|
|
873
|
+
/** Forget the address: nothing is sent to it again. */
|
|
874
|
+
clear(): Promise<INotificationAddressView>;
|
|
875
|
+
/** Send the fixed test message to the address alone, and say in words that name no address if it did not take it. */
|
|
876
|
+
test(): Promise<void>;
|
|
877
|
+
private send;
|
|
878
|
+
}
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region src/personal/delivery/question-delivery.d.ts
|
|
881
|
+
interface IQuestionDeliveryOptions {
|
|
882
|
+
/** The person's limits; none stored means the defaults. */
|
|
883
|
+
readonly settings: IDeliveryStore<IDeliverySettings>;
|
|
884
|
+
readonly state: IDeliveryStore<IDeliveryState>;
|
|
885
|
+
/**
|
|
886
|
+
* Where the person is told; a message goes to every sink. A function is asked again for each message,
|
|
887
|
+
* so a sink that exists only while the person has set it up is there for exactly that long.
|
|
888
|
+
*/
|
|
889
|
+
readonly sinks: readonly IDeliverySink[] | (() => Promise<readonly IDeliverySink[]>);
|
|
890
|
+
/** Where a held question is looked up again, to see whether it still waits for an answer. */
|
|
891
|
+
readonly feed: IDeliveryFeed;
|
|
892
|
+
/** The time of the machine running the agent; local day and local clock are read from it. */
|
|
893
|
+
readonly now?: () => Date;
|
|
894
|
+
/** How long a sink may take before its attempt is given up. */
|
|
895
|
+
readonly sinkTimeoutMs?: number;
|
|
896
|
+
}
|
|
897
|
+
declare class QuestionDelivery {
|
|
898
|
+
private readonly options;
|
|
899
|
+
private readonly now;
|
|
900
|
+
private readonly sinkTimeoutMs;
|
|
901
|
+
/** Decisions, pushes and digests go one at a time, so two questions cannot both pass the same limit. */
|
|
902
|
+
private readonly deliveries;
|
|
903
|
+
private readonly changes;
|
|
904
|
+
constructor(options: IQuestionDeliveryOptions);
|
|
905
|
+
private limits;
|
|
906
|
+
/** The counters for the local day of `at`: a new day starts the count over and keeps what is held. */
|
|
907
|
+
private load;
|
|
908
|
+
private attempt;
|
|
909
|
+
private sinks;
|
|
910
|
+
/** Send to every sink, once; how many took it. */
|
|
911
|
+
private send;
|
|
912
|
+
/** The held questions that still wait for an answer; answered, withdrawn and vanished ones drop out. */
|
|
913
|
+
private stillOpen;
|
|
914
|
+
/**
|
|
915
|
+
* A question was asked. It is pushed now, held for the digest or left alone as the person's limits
|
|
916
|
+
* say; a push counts toward today's limit only when a sink took it.
|
|
917
|
+
*/
|
|
918
|
+
onAsked(event: ICaseAskedEvent): Promise<void>;
|
|
919
|
+
/**
|
|
920
|
+
* Called every minute and once at start. Sends the day's one digest when its time has come, outside
|
|
921
|
+
* quiet hours, and some held question still waits for an answer; then forgets what was held and
|
|
922
|
+
* records the day, so a digest is attempted once a day.
|
|
923
|
+
*/
|
|
924
|
+
tick(): Promise<void>;
|
|
925
|
+
/** The person's limits, how many pushes are used today, and how many questions wait for the digest. */
|
|
926
|
+
status(): Promise<IDeliveryStatus>;
|
|
927
|
+
/**
|
|
928
|
+
* Change the person's limits: only what the change names, refused whole when any part is not valid.
|
|
929
|
+
* Only the person's own request reaches this; no tool does.
|
|
930
|
+
*/
|
|
931
|
+
updateSettings(change: unknown): Promise<IDeliverySettings>;
|
|
932
|
+
/** Resolves when everything started so far has finished. */
|
|
933
|
+
idle(): Promise<void>;
|
|
934
|
+
}
|
|
935
|
+
//#endregion
|
|
936
|
+
//#region src/personal/delivery/stores.d.ts
|
|
937
|
+
declare function createMemoryDeliveryStore<T>(initial?: T): IDeliveryStore<T>;
|
|
938
|
+
declare function createFileDeliveryStores(directory: string): {
|
|
939
|
+
readonly settings: IDeliveryStore<IDeliverySettings>;
|
|
940
|
+
readonly state: IDeliveryStore<IDeliveryState>;
|
|
941
|
+
};
|
|
942
|
+
//#endregion
|
|
391
943
|
//#region src/personal/goals/file-store.d.ts
|
|
392
944
|
declare function createFileGoalStore(directory: string): IGoalStore;
|
|
393
945
|
//#endregion
|
|
@@ -403,7 +955,10 @@ declare const GOAL_TOOL_NAMES: {
|
|
|
403
955
|
declare function renderGoal(goal: IGoal): string;
|
|
404
956
|
declare function createGoalTools(book: GoalBook): FunctionTool[];
|
|
405
957
|
declare const GOAL_INSTRUCTIONS: string;
|
|
406
|
-
/**
|
|
958
|
+
/**
|
|
959
|
+
* What a goal run's session is told, on top of the agent's usual instructions. A goal on a case is not
|
|
960
|
+
* named: its title is the case's, which the agent wrote from content other people wrote.
|
|
961
|
+
*/
|
|
407
962
|
declare function goalRunInstructions(goal: IGoal): string;
|
|
408
963
|
//#endregion
|
|
409
964
|
//#region src/personal/ideas/ideas.d.ts
|
|
@@ -468,5 +1023,551 @@ declare const IDEA_TOOL_NAMES: {
|
|
|
468
1023
|
declare function createIdeaTools(book: IdeaBook): FunctionTool[];
|
|
469
1024
|
declare const IDEA_INSTRUCTIONS = "When the person mentions something to come back to later, keep it with IdeaAdd. You may suggest ideas of your own, marked as yours; never act on an idea until the person takes it up.";
|
|
470
1025
|
//#endregion
|
|
471
|
-
|
|
1026
|
+
//#region src/personal/channels/types.d.ts
|
|
1027
|
+
/**
|
|
1028
|
+
* The standard channel contract: how any messenger plugs into a personal agent.
|
|
1029
|
+
*
|
|
1030
|
+
* An adapter turns one platform into this contract and nothing more. It declares what its platform
|
|
1031
|
+
* can do, so the agent degrades by declaration rather than by platform name, and it reports who sent
|
|
1032
|
+
* each message as the platform authenticated them. Everything an adapter delivers (the carrier and the
|
|
1033
|
+
* payload) is untrusted: the hub, not the adapter, decides whether a sender is the person the agent
|
|
1034
|
+
* works for, and an approval is only ever a structured action from that person, never text the model
|
|
1035
|
+
* reads.
|
|
1036
|
+
*/
|
|
1037
|
+
/** What a platform can carry, declared by its adapter. */
|
|
1038
|
+
interface IChannelCapabilities {
|
|
1039
|
+
/** Structured actions such as approve and decline buttons, answered as data, not text. */
|
|
1040
|
+
readonly actions: boolean;
|
|
1041
|
+
readonly attachments: boolean;
|
|
1042
|
+
readonly voice: boolean;
|
|
1043
|
+
/** The longest text one message may carry, when the platform limits it. */
|
|
1044
|
+
readonly maxTextLength?: number;
|
|
1045
|
+
}
|
|
1046
|
+
/** A message a platform delivered. */
|
|
1047
|
+
interface IChannelMessage {
|
|
1048
|
+
/** The conversation on that platform (a chat, a thread, a direct-message channel). */
|
|
1049
|
+
readonly conversationId: string;
|
|
1050
|
+
/** The sender as the platform authenticated them; the hub checks it against the owner's identity. */
|
|
1051
|
+
readonly senderId: string;
|
|
1052
|
+
readonly text: string;
|
|
1053
|
+
}
|
|
1054
|
+
/** The answer to an approval request, given through a platform's structured action. */
|
|
1055
|
+
interface IChannelApprovalAnswer {
|
|
1056
|
+
readonly approvalId: string;
|
|
1057
|
+
readonly approve: boolean;
|
|
1058
|
+
readonly senderId: string;
|
|
1059
|
+
}
|
|
1060
|
+
/** What the hub hands an adapter when it starts it. */
|
|
1061
|
+
interface IChannelHandler {
|
|
1062
|
+
onMessage(message: IChannelMessage): Promise<void>;
|
|
1063
|
+
onApprovalAnswer(answer: IChannelApprovalAnswer): Promise<void>;
|
|
1064
|
+
}
|
|
1065
|
+
interface IChannelApprovalRequest {
|
|
1066
|
+
readonly conversationId: string;
|
|
1067
|
+
readonly approvalId: string;
|
|
1068
|
+
readonly title: string;
|
|
1069
|
+
/** What will happen if approved: the action and where it goes. */
|
|
1070
|
+
readonly detail: string;
|
|
1071
|
+
}
|
|
1072
|
+
interface IChannelAdapter {
|
|
1073
|
+
/** A stable name for the platform, such as `fixture` or a messenger's name. */
|
|
1074
|
+
readonly id: string;
|
|
1075
|
+
readonly capabilities: IChannelCapabilities;
|
|
1076
|
+
start(handler: IChannelHandler): Promise<void>;
|
|
1077
|
+
stop(): Promise<void>;
|
|
1078
|
+
send(conversationId: string, text: string): Promise<void>;
|
|
1079
|
+
/** Present when `capabilities.actions` is true: ask with approve and decline actions. */
|
|
1080
|
+
requestApproval?(request: IChannelApprovalRequest): Promise<void>;
|
|
1081
|
+
}
|
|
1082
|
+
//#endregion
|
|
1083
|
+
//#region src/personal/channels/hub.d.ts
|
|
1084
|
+
/** Runs one turn for a channel conversation and returns the agent's reply. */
|
|
1085
|
+
type TChannelTurn = (key: {
|
|
1086
|
+
readonly channel: string;
|
|
1087
|
+
readonly conversationId: string;
|
|
1088
|
+
}, text: string) => Promise<string>;
|
|
1089
|
+
/** Answers an approval waiting in the feed. */
|
|
1090
|
+
type TChannelApprovalAnswer = (approvalId: string, approve: boolean) => Promise<void>;
|
|
1091
|
+
interface IChannelBinding {
|
|
1092
|
+
readonly adapter: IChannelAdapter;
|
|
1093
|
+
/** The owner's sender ids on this platform, verified when the channel was connected. */
|
|
1094
|
+
readonly ownerSenderIds: readonly string[];
|
|
1095
|
+
/** Where approvals and notices go on this platform. */
|
|
1096
|
+
readonly notifyConversationId?: string;
|
|
1097
|
+
}
|
|
1098
|
+
interface IChannelHubOptions {
|
|
1099
|
+
readonly runTurn: TChannelTurn;
|
|
1100
|
+
readonly answerApproval: TChannelApprovalAnswer;
|
|
1101
|
+
/** Called when a message from someone other than the owner is dropped; for the host's log. */
|
|
1102
|
+
readonly onRefused?: (channel: string, senderId: string) => void;
|
|
1103
|
+
}
|
|
1104
|
+
interface IChannelHub {
|
|
1105
|
+
connect(binding: IChannelBinding): Promise<void>;
|
|
1106
|
+
disconnect(channelId: string): Promise<void>;
|
|
1107
|
+
/** Tell the owner on every connected channel that an approval waits, with actions where possible. */
|
|
1108
|
+
announceApproval(request: Omit<IChannelApprovalRequest, 'conversationId'>): Promise<void>;
|
|
1109
|
+
/** Tell the owner something on every connected channel. */
|
|
1110
|
+
notify(text: string): Promise<void>;
|
|
1111
|
+
channels(): readonly {
|
|
1112
|
+
readonly id: string;
|
|
1113
|
+
readonly capabilities: IChannelAdapter['capabilities'];
|
|
1114
|
+
}[];
|
|
1115
|
+
}
|
|
1116
|
+
/** Split text so each part fits the platform's limit, at line or word boundaries where possible. */
|
|
1117
|
+
declare function splitForChannel(text: string, limit: number | undefined): string[];
|
|
1118
|
+
declare function createChannelHub(options: IChannelHubOptions): IChannelHub;
|
|
1119
|
+
//#endregion
|
|
1120
|
+
//#region src/personal/channels/fixture.d.ts
|
|
1121
|
+
interface IFixtureChannel extends IChannelAdapter {
|
|
1122
|
+
/** Deliver a message as the platform would. */
|
|
1123
|
+
deliver(conversationId: string, senderId: string, text: string): Promise<void>;
|
|
1124
|
+
/** Press an approval's action as the platform would. */
|
|
1125
|
+
press(approvalId: string, approve: boolean, senderId: string): Promise<void>;
|
|
1126
|
+
readonly sent: readonly {
|
|
1127
|
+
readonly conversationId: string;
|
|
1128
|
+
readonly text: string;
|
|
1129
|
+
}[];
|
|
1130
|
+
readonly approvalRequests: readonly IChannelApprovalRequest[];
|
|
1131
|
+
}
|
|
1132
|
+
declare function createFixtureChannel(options?: {
|
|
1133
|
+
readonly id?: string;
|
|
1134
|
+
readonly capabilities?: Partial<IChannelCapabilities>;
|
|
1135
|
+
}): IFixtureChannel;
|
|
1136
|
+
//#endregion
|
|
1137
|
+
//#region src/personal/spaces/spaces.d.ts
|
|
1138
|
+
interface ISpace {
|
|
1139
|
+
readonly id: string;
|
|
1140
|
+
readonly name: string;
|
|
1141
|
+
/** How the person wants the agent to work in this space, in their words. */
|
|
1142
|
+
readonly instructions: string;
|
|
1143
|
+
/** The tag the space's ideas carry. */
|
|
1144
|
+
readonly tag: string;
|
|
1145
|
+
/** Library pages pinned to the space, by page id, in pinning order. */
|
|
1146
|
+
readonly pages: readonly string[];
|
|
1147
|
+
readonly createdAt: string;
|
|
1148
|
+
readonly updatedAt: string;
|
|
1149
|
+
}
|
|
1150
|
+
interface ISpaceStore {
|
|
1151
|
+
list(): Promise<readonly ISpace[]>;
|
|
1152
|
+
get(id: string): Promise<ISpace | undefined>;
|
|
1153
|
+
put(space: ISpace): Promise<void>;
|
|
1154
|
+
remove(id: string): Promise<void>;
|
|
1155
|
+
}
|
|
1156
|
+
declare class SpaceRefusedError extends Error {
|
|
1157
|
+
constructor(reason: string);
|
|
1158
|
+
}
|
|
1159
|
+
/** A library page as the opening of a chat names it. */
|
|
1160
|
+
interface ISpacePage {
|
|
1161
|
+
readonly id: string;
|
|
1162
|
+
readonly title: string;
|
|
1163
|
+
}
|
|
1164
|
+
declare function createMemorySpaceStore(): ISpaceStore;
|
|
1165
|
+
/** Spaces in one owner-only `spaces.json`, rewritten atomically. */
|
|
1166
|
+
declare function createFileSpaceStore(directory: string): ISpaceStore;
|
|
1167
|
+
declare class SpaceBook {
|
|
1168
|
+
private readonly store;
|
|
1169
|
+
private readonly now;
|
|
1170
|
+
private sequence;
|
|
1171
|
+
constructor(options: {
|
|
1172
|
+
readonly store: ISpaceStore;
|
|
1173
|
+
readonly now?: () => Date;
|
|
1174
|
+
});
|
|
1175
|
+
private check;
|
|
1176
|
+
create(input: {
|
|
1177
|
+
readonly name: string;
|
|
1178
|
+
readonly instructions: string;
|
|
1179
|
+
}): Promise<ISpace>;
|
|
1180
|
+
list(): Promise<readonly ISpace[]>;
|
|
1181
|
+
get(id: string): Promise<ISpace | undefined>;
|
|
1182
|
+
private existing;
|
|
1183
|
+
/** Pin a library page; the caller has checked that the page exists. Pinning twice is a no-op. */
|
|
1184
|
+
pin(id: string, pageId: string): Promise<ISpace>;
|
|
1185
|
+
unpin(id: string, pageId: string): Promise<ISpace>;
|
|
1186
|
+
update(id: string, input: {
|
|
1187
|
+
readonly name: string;
|
|
1188
|
+
readonly instructions: string;
|
|
1189
|
+
}): Promise<ISpace>;
|
|
1190
|
+
remove(id: string): Promise<void>;
|
|
1191
|
+
/**
|
|
1192
|
+
* The first message of a chat started in the space: the person's own instructions, named as such,
|
|
1193
|
+
* and the pinned pages that still exist, by title and id so the agent can read them.
|
|
1194
|
+
*/
|
|
1195
|
+
opening(space: ISpace, pages?: readonly ISpacePage[]): string;
|
|
1196
|
+
}
|
|
1197
|
+
//#endregion
|
|
1198
|
+
//#region src/personal/connectors/types.d.ts
|
|
1199
|
+
/**
|
|
1200
|
+
* Connectors: external services the person connected once (mail, calendar, files, chat, notes, ...)
|
|
1201
|
+
* that the agent reads on demand and keeps in sync. A connector is data — a kind, an endpoint and the
|
|
1202
|
+
* person's decisions about its tools — and a protocol port reaches it. Nothing here holds a
|
|
1203
|
+
* credential or knows a protocol.
|
|
1204
|
+
*/
|
|
1205
|
+
/** What a connector is for. A tag the person and the agent read, not a code path. */
|
|
1206
|
+
type TConnectorKind = 'mail' | 'calendar' | 'files' | 'chat' | 'notes' | 'other';
|
|
1207
|
+
declare const CONNECTOR_KINDS: readonly TConnectorKind[];
|
|
1208
|
+
/**
|
|
1209
|
+
* How a service asks the person to sign in: `oauth` (a sign-in in their browser, the default), `token`
|
|
1210
|
+
* (a token they type once) or `none` (the service needs no sign-in).
|
|
1211
|
+
*/
|
|
1212
|
+
type TConnectorAuth = 'oauth' | 'token' | 'none';
|
|
1213
|
+
declare const CONNECTOR_AUTHS: readonly TConnectorAuth[];
|
|
1214
|
+
/** The person's own decision about one tool, over what the service claims about it. */
|
|
1215
|
+
type TToolDecision = 'read' | 'write' | 'blocked';
|
|
1216
|
+
/** What a tool is treated as: reading is allowed, writing is held for the person, blocked is never called. */
|
|
1217
|
+
type TToolAccess = TToolDecision;
|
|
1218
|
+
interface IConnector {
|
|
1219
|
+
/** `connector-` and a slug; unique within one person's connectors. */
|
|
1220
|
+
readonly id: string;
|
|
1221
|
+
readonly title: string;
|
|
1222
|
+
readonly kind: TConnectorKind;
|
|
1223
|
+
/** Which protocol adapter reaches it, such as `mcp`. */
|
|
1224
|
+
readonly protocol: string;
|
|
1225
|
+
/** Where the service is reached: an `https` address that carries no credential. */
|
|
1226
|
+
readonly endpoint: string;
|
|
1227
|
+
/** How it asks the person to sign in; absent means `oauth`. */
|
|
1228
|
+
readonly auth?: TConnectorAuth;
|
|
1229
|
+
/**
|
|
1230
|
+
* With `token`: the header the token goes in when it is not the standard `Authorization` bearer.
|
|
1231
|
+
* A name only; the token itself is never in a connector.
|
|
1232
|
+
*/
|
|
1233
|
+
readonly tokenHeader?: string;
|
|
1234
|
+
/**
|
|
1235
|
+
* What the person registered with the service's authorization server when it has no dynamic
|
|
1236
|
+
* registration. Public values only: a secret never lives in a connector (it is typed at sign-in).
|
|
1237
|
+
*/
|
|
1238
|
+
readonly oauth?: {
|
|
1239
|
+
readonly clientId?: string;
|
|
1240
|
+
readonly scopes?: readonly string[];
|
|
1241
|
+
/**
|
|
1242
|
+
* Plain-word parameters the person's sign-in adds to the authorization request, for a service
|
|
1243
|
+
* that needs one to keep a sign-in long-lived. Never a secret.
|
|
1244
|
+
*/
|
|
1245
|
+
readonly authorizationParams?: Readonly<Record<string, string>>;
|
|
1246
|
+
};
|
|
1247
|
+
/** The person's decisions, by tool name. A tool without one is sorted by what the service claims. */
|
|
1248
|
+
readonly decisions: Readonly<Record<string, TToolDecision>>;
|
|
1249
|
+
/**
|
|
1250
|
+
* What deserves a question, in the person's own words: one short paragraph a sync run reads before
|
|
1251
|
+
* it looks at the service. Absent means the default for the connector's kind. Only the person sets
|
|
1252
|
+
* it; nothing read from the service ever does.
|
|
1253
|
+
*/
|
|
1254
|
+
readonly attention?: string;
|
|
1255
|
+
readonly createdAt: string;
|
|
1256
|
+
readonly updatedAt: string;
|
|
1257
|
+
}
|
|
1258
|
+
/** What a service says about a tool's effect: a claim, never a guarantee. */
|
|
1259
|
+
interface IConnectorToolHints {
|
|
1260
|
+
readonly readOnly?: boolean;
|
|
1261
|
+
readonly destructive?: boolean;
|
|
1262
|
+
readonly idempotent?: boolean;
|
|
1263
|
+
readonly openWorld?: boolean;
|
|
1264
|
+
}
|
|
1265
|
+
/** A tool a connected service offers, as the service declared it. */
|
|
1266
|
+
interface IConnectorToolInfo {
|
|
1267
|
+
readonly name: string;
|
|
1268
|
+
readonly description?: string;
|
|
1269
|
+
/** The input the tool takes, JSON-Schema-shaped. */
|
|
1270
|
+
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
1271
|
+
readonly hints?: IConnectorToolHints;
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Where the person stands with a connector, as a fixed word:
|
|
1275
|
+
* `not-connected`, `connecting` (the person has to finish signing in), `connected`,
|
|
1276
|
+
* `needs-sign-in` (a credential was kept but can no longer be used) or `failed`.
|
|
1277
|
+
*/
|
|
1278
|
+
type TConnectorState = 'not-connected' | 'connecting' | 'connected' | 'needs-sign-in' | 'failed';
|
|
1279
|
+
interface IConnectorStatus {
|
|
1280
|
+
readonly state: TConnectorState;
|
|
1281
|
+
/** Why a sign-in or a connection failed, as a fixed word; never text from a service or a token. */
|
|
1282
|
+
readonly reason?: string;
|
|
1283
|
+
/** While connecting: where the person's browser goes to consent. */
|
|
1284
|
+
readonly authorizationUrl?: string;
|
|
1285
|
+
/** While connecting: the address the consent returns to, which a pre-registered client must list. */
|
|
1286
|
+
readonly redirectUri?: string;
|
|
1287
|
+
/**
|
|
1288
|
+
* While connected: the scopes the service says it granted, as scope words. What the person
|
|
1289
|
+
* consented to is this, so it is shown as the authoritative permission; never a token or derived
|
|
1290
|
+
* from one.
|
|
1291
|
+
*/
|
|
1292
|
+
readonly scope?: string;
|
|
1293
|
+
}
|
|
1294
|
+
/** Where the person's browser reaches this agent; the consent returns there. */
|
|
1295
|
+
interface ISignInContext {
|
|
1296
|
+
/** Where the person's browser reaches this agent; an `oauth` sign-in needs it, the others do not. */
|
|
1297
|
+
readonly origin?: string;
|
|
1298
|
+
/**
|
|
1299
|
+
* The token the person typed for a `token` connector. Held until it is checked and then only in
|
|
1300
|
+
* the owner-only credential directory: never in a connector, an answer or a log.
|
|
1301
|
+
*/
|
|
1302
|
+
readonly token?: string;
|
|
1303
|
+
/**
|
|
1304
|
+
* The client secret the person typed for this sign-in, for a service that gives its pre-registered
|
|
1305
|
+
* client one. It is held only until the sign-in ends and then only with the credential the
|
|
1306
|
+
* protocol keeps owner-only: never in a connector, an answer or a log.
|
|
1307
|
+
*/
|
|
1308
|
+
readonly clientSecret?: string;
|
|
1309
|
+
}
|
|
1310
|
+
type TRevocation = 'revoked' | 'partial' | 'unsupported' | 'failed' | 'not-attempted';
|
|
1311
|
+
interface IDisconnectOutcome {
|
|
1312
|
+
/** Whether a credential was kept before. It is gone now whatever the service answered. */
|
|
1313
|
+
readonly removed: boolean;
|
|
1314
|
+
readonly revocation: TRevocation;
|
|
1315
|
+
}
|
|
1316
|
+
interface IConnectorCallResult {
|
|
1317
|
+
/** What the service returned, as text. It is data from the service, never instructions. */
|
|
1318
|
+
readonly text: string;
|
|
1319
|
+
readonly isError: boolean;
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* One protocol's way to reach a service. The composition root supplies it, because reaching a
|
|
1323
|
+
* service needs a host (network, files, a browser sign-in), and the pack stays neutral.
|
|
1324
|
+
*/
|
|
1325
|
+
interface IConnectorProtocol {
|
|
1326
|
+
readonly id: string;
|
|
1327
|
+
status(connector: IConnector): Promise<IConnectorStatus>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Start the person's sign-in. Returns at once with where their browser goes; the sign-in finishes
|
|
1330
|
+
* on its own when the browser comes back, and `status` then says `connected` or `failed`.
|
|
1331
|
+
*/
|
|
1332
|
+
signIn(connector: IConnector, context: ISignInContext): Promise<IConnectorStatus>;
|
|
1333
|
+
/** Delete the credential first, then ask the service to revoke it. */
|
|
1334
|
+
signOut(connector: IConnector): Promise<IDisconnectOutcome>;
|
|
1335
|
+
tools(connector: IConnector): Promise<readonly IConnectorToolInfo[]>;
|
|
1336
|
+
call(connector: IConnector, tool: string, args: Readonly<Record<string, unknown>>, options?: {
|
|
1337
|
+
readonly signal?: AbortSignal;
|
|
1338
|
+
}): Promise<IConnectorCallResult>;
|
|
1339
|
+
/** Let go of what is held for a connector that is being removed. */
|
|
1340
|
+
forget(connector: IConnector): Promise<void>;
|
|
1341
|
+
close(): Promise<void>;
|
|
1342
|
+
}
|
|
1343
|
+
//#endregion
|
|
1344
|
+
//#region src/personal/connectors/book.d.ts
|
|
1345
|
+
interface IConnectorStore {
|
|
1346
|
+
list(): Promise<readonly IConnector[]>;
|
|
1347
|
+
get(id: string): Promise<IConnector | undefined>;
|
|
1348
|
+
put(connector: IConnector): Promise<void>;
|
|
1349
|
+
remove(id: string): Promise<void>;
|
|
1350
|
+
}
|
|
1351
|
+
declare class ConnectorRefusedError extends Error {
|
|
1352
|
+
constructor(reason: string);
|
|
1353
|
+
}
|
|
1354
|
+
declare function createMemoryConnectorStore(): IConnectorStore;
|
|
1355
|
+
/** Connectors in one owner-only `connectors.json`, rewritten atomically. */
|
|
1356
|
+
declare function createFileConnectorStore(directory: string): IConnectorStore;
|
|
1357
|
+
interface ICreateConnectorInput {
|
|
1358
|
+
readonly title: string;
|
|
1359
|
+
readonly kind: TConnectorKind;
|
|
1360
|
+
readonly protocol: string;
|
|
1361
|
+
readonly endpoint: string;
|
|
1362
|
+
readonly auth?: TConnectorAuth;
|
|
1363
|
+
readonly tokenHeader?: string;
|
|
1364
|
+
readonly oauth?: {
|
|
1365
|
+
readonly clientId?: string;
|
|
1366
|
+
readonly scopes?: readonly string[];
|
|
1367
|
+
readonly authorizationParams?: Readonly<Record<string, string>>;
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
declare class ConnectorBook {
|
|
1371
|
+
private readonly store;
|
|
1372
|
+
private readonly now;
|
|
1373
|
+
private sequence;
|
|
1374
|
+
constructor(options: {
|
|
1375
|
+
readonly store: IConnectorStore;
|
|
1376
|
+
readonly now?: () => Date;
|
|
1377
|
+
});
|
|
1378
|
+
create(input: ICreateConnectorInput): Promise<IConnector>;
|
|
1379
|
+
list(): Promise<readonly IConnector[]>;
|
|
1380
|
+
get(id: string): Promise<IConnector | undefined>;
|
|
1381
|
+
existing(id: string): Promise<IConnector>;
|
|
1382
|
+
/** Record the person's decision about one tool, or clear it with `undefined`. */
|
|
1383
|
+
decide(id: string, tool: string, decision: TToolDecision | undefined): Promise<IConnector>;
|
|
1384
|
+
/** Record what the person wants to be asked about, in their own words; empty text clears it. */
|
|
1385
|
+
setAttention(id: string, text: string): Promise<IConnector>;
|
|
1386
|
+
remove(id: string): Promise<void>;
|
|
1387
|
+
}
|
|
1388
|
+
//#endregion
|
|
1389
|
+
//#region src/personal/connectors/attention.d.ts
|
|
1390
|
+
/** The longest attention text kept: one short paragraph. */
|
|
1391
|
+
declare const ATTENTION_MAX_CHARACTERS = 600;
|
|
1392
|
+
/** What a connector of this kind asks about until the person words it themselves. */
|
|
1393
|
+
declare function defaultAttention(kind: TConnectorKind): string;
|
|
1394
|
+
/**
|
|
1395
|
+
* The words a sync run is given: the person's own text, or the default for the connector's kind. A
|
|
1396
|
+
* stored text that cannot be used as written (a hand-edited or damaged file) is normalised the way a
|
|
1397
|
+
* saved one is, and an unusable one falls back to the default rather than guessing at it.
|
|
1398
|
+
*/
|
|
1399
|
+
declare function effectiveAttention(connector: IConnector): string;
|
|
1400
|
+
//#endregion
|
|
1401
|
+
//#region src/personal/connectors/catalog.d.ts
|
|
1402
|
+
interface IConnectorCatalogEntry {
|
|
1403
|
+
readonly title: string;
|
|
1404
|
+
readonly endpoint: string;
|
|
1405
|
+
readonly kind: TConnectorKind;
|
|
1406
|
+
/** How the service is expected to be signed in to; the person can change it before adding. */
|
|
1407
|
+
readonly auth: TConnectorAuth;
|
|
1408
|
+
readonly tokenHeader?: string;
|
|
1409
|
+
/**
|
|
1410
|
+
* A client the owner registered with the service for this agent, so a person need not register one:
|
|
1411
|
+
* only the owner's file can carry it. The client's secret, if it has one, is never in a suggestion;
|
|
1412
|
+
* the person types it at sign-in.
|
|
1413
|
+
*/
|
|
1414
|
+
readonly oauth?: {
|
|
1415
|
+
readonly clientId?: string;
|
|
1416
|
+
readonly scopes?: readonly string[];
|
|
1417
|
+
readonly authorizationParams?: Readonly<Record<string, string>>;
|
|
1418
|
+
};
|
|
1419
|
+
readonly description?: string;
|
|
1420
|
+
/** Where the suggestion came from, as a word the page shows. */
|
|
1421
|
+
readonly source: string;
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* A catalog entry from one raw record, or `undefined` when the record is not a suggestion the book
|
|
1425
|
+
* would accept (a missing or unusable address, an unknown sign-in way, a header the connection owns).
|
|
1426
|
+
*/
|
|
1427
|
+
declare function catalogEntryOf(raw: unknown, source: string): IConnectorCatalogEntry | undefined;
|
|
1428
|
+
/** The services of one page of a registry's answer that can be added here, one entry per address. */
|
|
1429
|
+
declare function catalogEntriesFromRegistry(page: unknown): IConnectorCatalogEntry[];
|
|
1430
|
+
//#endregion
|
|
1431
|
+
//#region src/personal/connectors/registry.d.ts
|
|
1432
|
+
interface IConnectorToolView extends IConnectorToolInfo {
|
|
1433
|
+
/** What the tool is treated as. */
|
|
1434
|
+
readonly access: TToolAccess;
|
|
1435
|
+
/** The person's own decision, when there is one. */
|
|
1436
|
+
readonly decision?: TToolDecision;
|
|
1437
|
+
}
|
|
1438
|
+
interface IConnectorView {
|
|
1439
|
+
readonly connector: IConnector;
|
|
1440
|
+
readonly status: IConnectorStatus;
|
|
1441
|
+
/** The tools a connected service offers; absent while it is not connected or cannot be reached. */
|
|
1442
|
+
readonly tools?: readonly IConnectorToolView[];
|
|
1443
|
+
}
|
|
1444
|
+
interface IConnectorRegistryOptions {
|
|
1445
|
+
readonly book: ConnectorBook;
|
|
1446
|
+
readonly protocols: readonly IConnectorProtocol[];
|
|
1447
|
+
/** How long a service's tool list is reused; a new decision or a miss refreshes it sooner. */
|
|
1448
|
+
readonly toolCacheMs?: number;
|
|
1449
|
+
readonly now?: () => number;
|
|
1450
|
+
}
|
|
1451
|
+
/**
|
|
1452
|
+
* What a tool is treated as: the person's decision first, else the service's read-only claim, else a
|
|
1453
|
+
* write. A decision that is present but not one of the three words (a hand-edited or damaged file)
|
|
1454
|
+
* is something the person said that cannot be read, so the tool is blocked rather than guessed at.
|
|
1455
|
+
*/
|
|
1456
|
+
declare function classifyTool(connector: IConnector, tool: IConnectorToolInfo): TToolAccess;
|
|
1457
|
+
declare class ConnectorRegistry {
|
|
1458
|
+
private readonly book;
|
|
1459
|
+
private readonly protocols;
|
|
1460
|
+
private readonly cacheMs;
|
|
1461
|
+
private readonly now;
|
|
1462
|
+
private readonly cache;
|
|
1463
|
+
private readonly reads;
|
|
1464
|
+
constructor(options: IConnectorRegistryOptions);
|
|
1465
|
+
private protocolOf;
|
|
1466
|
+
private toolsOf;
|
|
1467
|
+
private viewTools;
|
|
1468
|
+
view(id: string, options?: {
|
|
1469
|
+
readonly refresh?: boolean;
|
|
1470
|
+
}): Promise<IConnectorView>;
|
|
1471
|
+
list(): Promise<readonly IConnectorView[]>;
|
|
1472
|
+
/** Start the person's sign-in; the answer says where their browser goes. */
|
|
1473
|
+
signIn(id: string, context: ISignInContext): Promise<IConnectorStatus>;
|
|
1474
|
+
disconnect(id: string): Promise<IDisconnectOutcome>;
|
|
1475
|
+
/** Disconnect and forget a connector: the credential is deleted before anything else. */
|
|
1476
|
+
remove(id: string): Promise<IDisconnectOutcome>;
|
|
1477
|
+
decide(id: string, tool: string, decision: TToolDecision | undefined): Promise<IConnector>;
|
|
1478
|
+
/** One connector's tools as the model should see them. */
|
|
1479
|
+
describe(id: string): Promise<IConnectorView>;
|
|
1480
|
+
private notReady;
|
|
1481
|
+
private resolve;
|
|
1482
|
+
/**
|
|
1483
|
+
* How many reads on a connector worked and how many did not (refused, errored or reported as an
|
|
1484
|
+
* error by the service), counted since this agent started. A caller that wants to know whether
|
|
1485
|
+
* a stretch of work could read compares the counts before and after.
|
|
1486
|
+
*/
|
|
1487
|
+
readCounts(id: string): {
|
|
1488
|
+
readonly succeeded: number;
|
|
1489
|
+
readonly failed: number;
|
|
1490
|
+
};
|
|
1491
|
+
private noteRead;
|
|
1492
|
+
/** Call a tool that only reads. A tool that writes is refused here, whatever the caller says it is. */
|
|
1493
|
+
read(id: string, tool: string, args: Readonly<Record<string, unknown>>, signal?: AbortSignal): Promise<IConnectorCallResult>;
|
|
1494
|
+
/** Call a tool that writes or sends. The person's approval is the caller's gate; a read tool is refused. */
|
|
1495
|
+
act(id: string, tool: string, args: Readonly<Record<string, unknown>>, signal?: AbortSignal): Promise<IConnectorCallResult>;
|
|
1496
|
+
close(): Promise<void>;
|
|
1497
|
+
}
|
|
1498
|
+
//#endregion
|
|
1499
|
+
//#region src/personal/connectors/tools.d.ts
|
|
1500
|
+
declare const CONNECTOR_TOOL_NAMES: {
|
|
1501
|
+
readonly list: "ConnectorList";
|
|
1502
|
+
readonly read: "ConnectorRead";
|
|
1503
|
+
readonly act: "ConnectorAct";
|
|
1504
|
+
readonly keep: "ConnectorKeep";
|
|
1505
|
+
};
|
|
1506
|
+
declare function createConnectorTools(registry: ConnectorRegistry): FunctionTool[];
|
|
1507
|
+
declare const CONNECTOR_INSTRUCTIONS: string;
|
|
1508
|
+
//#endregion
|
|
1509
|
+
//#region src/personal/connectors/keep.d.ts
|
|
1510
|
+
/** Where a claim pulled from a connector of this kind says it came from. */
|
|
1511
|
+
declare function originOfConnector(kind: TConnectorKind): TClaimOrigin;
|
|
1512
|
+
/** The reference a claim carries: the connector, then the item it was read from. */
|
|
1513
|
+
declare function connectorReference(connectorId: string, item?: string): string;
|
|
1514
|
+
/** How many claims in the library came from this connector. */
|
|
1515
|
+
declare function countPulled(wiki: KnowledgeWiki, connectorId: string): Promise<number>;
|
|
1516
|
+
/** Remove every claim pulled from this connector, and nothing the person or another source said. */
|
|
1517
|
+
declare function forgetPulled(wiki: KnowledgeWiki, connectorId: string): Promise<number>;
|
|
1518
|
+
/**
|
|
1519
|
+
* The tool that files a fact read from a connector into the library. It always files with the
|
|
1520
|
+
* origin and reference the connector's kind and id decide, so what a sync keeps can be told from
|
|
1521
|
+
* what the person said and removed with the connection, and it only adds: a changed fact is another
|
|
1522
|
+
* claim beside the old one, so content read from a service never rewrites what the person said.
|
|
1523
|
+
*/
|
|
1524
|
+
declare function createConnectorKeepTool(options: {
|
|
1525
|
+
readonly book: ConnectorBook;
|
|
1526
|
+
readonly wiki: KnowledgeWiki;
|
|
1527
|
+
}): FunctionTool;
|
|
1528
|
+
//#endregion
|
|
1529
|
+
//#region src/personal/connectors/sync.d.ts
|
|
1530
|
+
/** How often a sync may run: not more often than a run is worth, not less often than weekly. */
|
|
1531
|
+
declare const SYNC_MIN_MINUTES = 15;
|
|
1532
|
+
declare const SYNC_MAX_MINUTES: number;
|
|
1533
|
+
/**
|
|
1534
|
+
* The only tools a sync run has. Content from the service is written by others, so a run can read it,
|
|
1535
|
+
* look in the library, add what it finds and keep a case on what the person should be asked, and nothing
|
|
1536
|
+
* else: it cannot change the service, reach the web or the files, drive the browser, rewrite what the
|
|
1537
|
+
* person said or set up goals. The case tools touch only the agent's own record and the feed. It is a list of
|
|
1538
|
+
* what is allowed, not of what is withheld: a tool added later is then not offered until it is named.
|
|
1539
|
+
*/
|
|
1540
|
+
declare function syncRunTools(): string[];
|
|
1541
|
+
/** What a sync run is asked, as the goal's own text: short, and shown to the person with the goal. */
|
|
1542
|
+
declare function syncGoalPrompt(connector: IConnector): string;
|
|
1543
|
+
/**
|
|
1544
|
+
* What a sync run is told about how to work, for this run: the connector, where to start, and the
|
|
1545
|
+
* person's own words about what deserves a question. Those words come before the rules for handling
|
|
1546
|
+
* what is read, and they decide only what the run asks about: they add no tool and no permission.
|
|
1547
|
+
*/
|
|
1548
|
+
declare function syncRunInstructions(connector: IConnector, since: string | undefined): string;
|
|
1549
|
+
interface IConnectorSyncStatus {
|
|
1550
|
+
readonly goalId: string;
|
|
1551
|
+
readonly everyMinutes: number;
|
|
1552
|
+
readonly status: IGoal['status'];
|
|
1553
|
+
readonly lastRunAt?: string;
|
|
1554
|
+
readonly nextRunAt?: string;
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* The goals that keep connectors in sync: one per connector, found by the connector it names. `halt`
|
|
1558
|
+
* ends a run that is in progress, which a goal cannot be removed during.
|
|
1559
|
+
*/
|
|
1560
|
+
declare class ConnectorSync {
|
|
1561
|
+
private readonly goals;
|
|
1562
|
+
private readonly halt?;
|
|
1563
|
+
constructor(goals: GoalBook, halt?: ((goalId: string) => Promise<void>) | undefined);
|
|
1564
|
+
private goalOf;
|
|
1565
|
+
status(connectorId: string): Promise<IConnectorSyncStatus | undefined>;
|
|
1566
|
+
/** Turn sync on, or change how often it runs; a new sync is due at once, a changed one keeps its place. */
|
|
1567
|
+
enable(connector: IConnector, everyMinutes: number): Promise<IConnectorSyncStatus>;
|
|
1568
|
+
/** Turn sync off. The reports and runs it made are gone with the goal; what it kept stays in the library. */
|
|
1569
|
+
disable(connectorId: string): Promise<boolean>;
|
|
1570
|
+
}
|
|
1571
|
+
//#endregion
|
|
1572
|
+
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 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 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 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, parseNotificationAddress, renderGoal, renderPageForModel, renderPageMarkdown, renderView, splitForChannel, syncGoalPrompt, syncRunInstructions, syncRunTools, webhookMessage };
|
|
472
1573
|
//# sourceMappingURL=index.d.ts.map
|