@robota-sdk/agent-product 3.4.0 → 3.6.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.
@@ -131,21 +131,32 @@ declare class KnowledgeWiki {
131
131
  search(query: string, limit?: number): Promise<readonly ISearchHit[]>;
132
132
  /** The pages most relevant to a query, rendered for the model with provenance. */
133
133
  recall(query: string, limit?: number): Promise<string>;
134
+ /** The change log, newest first: what was filed, corrected, linked and forgotten, never forgotten text. */
135
+ log(limit?: number): Promise<readonly IWikiLogEntry[]>;
134
136
  /** Every page title and kind: what the model reads first, as an index. */
135
137
  index(): Promise<string>;
136
138
  /**
137
- * Forget a claim by id, or every current or retired claim containing `text`. Returns how many
138
- * claims were removed. A page left with no claims is deleted, and with it every link to it and
139
- * every log entry that named it, since a page's id is its title and can carry the fact itself.
139
+ * Forget a claim by id, every claim on a page, or every current or retired claim containing
140
+ * `text`. Returns how many claims were removed. A page left with no claims is deleted, and with it
141
+ * every link to it and every log entry that named it, since a page's id is its title and can carry
142
+ * the fact itself.
140
143
  */
141
144
  forget(target: {
142
145
  claimId: string;
146
+ } | {
147
+ pageId: string;
143
148
  } | {
144
149
  text: string;
145
150
  }): Promise<number>;
146
151
  /** Link two existing pages, named by id or title; a link is always a page id, never free text. */
147
152
  link(fromPage: string, toPage: string): Promise<void>;
148
- lint(): Promise<ILintReport>;
153
+ /**
154
+ * Check the wiki. By default the check is logged, as the agent's own maintenance; a person merely
155
+ * looking at the findings passes `record: false`, so looking never changes the wiki.
156
+ */
157
+ lint(options?: {
158
+ readonly record?: boolean;
159
+ }): Promise<ILintReport>;
149
160
  }
150
161
  //#endregion
151
162
  //#region src/personal/knowledge/file-store.d.ts
@@ -214,6 +225,13 @@ interface IBrowserActionResult {
214
225
  /** Present when the action made requests that write; they were held, not sent. */
215
226
  readonly held?: readonly IHeldSubmission[];
216
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
+ }
217
235
  interface IBrowserPort {
218
236
  open(url: string): Promise<IBrowserView>;
219
237
  view(): Promise<IBrowserView>;
@@ -227,6 +245,11 @@ interface IBrowserPort {
227
245
  readonly method: string;
228
246
  readonly url: string;
229
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>;
230
253
  close(): Promise<void>;
231
254
  }
232
255
  declare class BrowserUnavailableError extends Error {
@@ -249,5 +272,687 @@ declare function renderView(view: IBrowserView): string;
249
272
  declare function createBrowserTools(browser: IBrowserPort): FunctionTool[];
250
273
  declare const BROWSER_INSTRUCTIONS: string;
251
274
  //#endregion
252
- export { BROWSER_INSTRUCTIONS, BROWSER_TOOL_NAMES, BrowserNavigationRefusedError, BrowserUnavailableError, type IBrowserActionResult, type IBrowserMark, type IBrowserPort, type IBrowserView, type IClaim, type IClaimSource, type IHeldSubmission, type IKnowledgeStore, type IKnowledgeWikiOptions, type ILintReport, type IRememberInput, type IRememberResult, type ISearchHit, type IWikiLogEntry, type IWikiPage, KnowledgeWiki, PAGE_KINDS, SensitiveContentRefusedError, type TClaimOrigin, type TPageKind, type TWikiLogAction, WIKI_INSTRUCTIONS, WIKI_TOOL_NAMES, createBrowserTools, createFileKnowledgeStore, createMemoryKnowledgeStore, createWikiTools, pageIdFor, renderPageForModel, renderPageMarkdown, renderView };
275
+ //#region src/personal/goals/types.d.ts
276
+ /**
277
+ * Goals a personal agent works on while the person is away, and the feed it reports to.
278
+ *
279
+ * A goal is an instruction with a schedule. Each time it is due, a host runs it as one turn of its
280
+ * own session and records a run: what the agent did, what it only planned because a person had to
281
+ * approve it, and what it reported. Anything that needs the person, whether an approval or a result,
282
+ * goes to the feed, which outlives any open page.
283
+ */
284
+ type TGoalStatus = 'active' | 'running' | 'waiting' | 'paused' | 'done' | 'failed';
285
+ interface IGoal {
286
+ readonly id: string;
287
+ readonly title: string;
288
+ /** What the agent is asked to do on each run, in the person's words. */
289
+ readonly instructions: string;
290
+ /** Run again this many minutes after a run ends; absent runs the goal once. */
291
+ readonly everyMinutes?: number;
292
+ /** Change nothing while running: the agent may only look, and anything else is refused. */
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
+ readonly status: TGoalStatus;
297
+ /** When the goal is next due (ISO 8601); absent when it is not scheduled. */
298
+ readonly nextRunAt?: string;
299
+ readonly lastRunAt?: string;
300
+ readonly createdAt: string;
301
+ readonly updatedAt: string;
302
+ }
303
+ /** One thing the agent did or tried during a run: the audit trail. */
304
+ interface IGoalAction {
305
+ readonly at: string;
306
+ readonly tool: string;
307
+ /** A short description of the call, never a secret it carried. */
308
+ readonly detail: string;
309
+ readonly outcome: 'done' | 'error' | 'denied' | 'waiting-approval' | 'approved';
310
+ }
311
+ type TGoalRunOutcome = 'done' | 'failed' | 'interrupted';
312
+ interface IGoalRun {
313
+ readonly id: string;
314
+ readonly goalId: string;
315
+ readonly startedAt: string;
316
+ readonly endedAt?: string;
317
+ readonly outcome?: TGoalRunOutcome;
318
+ /** What the agent reported at the end of the run. */
319
+ readonly report?: string;
320
+ readonly actions: readonly IGoalAction[];
321
+ }
322
+ type TFeedKind = 'report' | 'approval' | 'notice';
323
+ type TApprovalState = 'pending' | 'approved' | 'denied' | 'expired';
324
+ interface IFeedItem {
325
+ readonly id: string;
326
+ readonly at: string;
327
+ readonly kind: TFeedKind;
328
+ readonly title: string;
329
+ readonly body: string;
330
+ readonly goalId?: string;
331
+ readonly runId?: string;
332
+ /** Present on an approval: the action that waits for the person. */
333
+ readonly approval?: {
334
+ readonly tool: string;
335
+ readonly detail: string;
336
+ readonly state: TApprovalState;
337
+ };
338
+ readonly dismissed: boolean;
339
+ }
340
+ /** Where goals, their runs and the feed live; a host supplies one per principal. */
341
+ interface IGoalStore {
342
+ listGoals(): Promise<readonly IGoal[]>;
343
+ getGoal(id: string): Promise<IGoal | undefined>;
344
+ putGoal(goal: IGoal): Promise<void>;
345
+ deleteGoal(id: string): Promise<void>;
346
+ putRun(run: IGoalRun): Promise<void>;
347
+ /** A goal's runs, newest first. */
348
+ listRuns(goalId: string, limit: number): Promise<readonly IGoalRun[]>;
349
+ putFeedItem(item: IFeedItem): Promise<void>;
350
+ getFeedItem(id: string): Promise<IFeedItem | undefined>;
351
+ /** Feed items, newest first. */
352
+ listFeed(limit: number): Promise<readonly IFeedItem[]>;
353
+ }
354
+ //#endregion
355
+ //#region src/personal/goals/goal-book.d.ts
356
+ interface IGoalBookOptions {
357
+ readonly store: IGoalStore;
358
+ readonly now?: () => Date;
359
+ }
360
+ interface ICreateGoalInput {
361
+ readonly title: string;
362
+ readonly instructions: string;
363
+ readonly everyMinutes?: number;
364
+ readonly readOnly?: boolean;
365
+ readonly connectorId?: string;
366
+ }
367
+ declare class GoalRefusedError extends Error {
368
+ constructor(reason: string);
369
+ }
370
+ declare class GoalBook {
371
+ private readonly store;
372
+ private readonly now;
373
+ private sequence;
374
+ constructor(options: IGoalBookOptions);
375
+ private stamp;
376
+ private mint;
377
+ private require;
378
+ private save;
379
+ create(input: ICreateGoalInput): Promise<IGoal>;
380
+ list(): Promise<readonly IGoal[]>;
381
+ get(id: string): Promise<IGoal | undefined>;
382
+ runs(goalId: string, limit?: number): Promise<readonly IGoalRun[]>;
383
+ /** Goals due now: active and scheduled at or before this moment. */
384
+ due(): Promise<readonly IGoal[]>;
385
+ pause(id: string): Promise<IGoal>;
386
+ /**
387
+ * Change how often a goal repeats. A run in progress keeps going and the next one follows the new
388
+ * interval; otherwise the goal is active again and due that long after its last run (at once if it
389
+ * never ran or that moment has passed).
390
+ */
391
+ reschedule(id: string, everyMinutes: number): Promise<IGoal>;
392
+ /** Make a paused, finished or failed goal due now. */
393
+ resume(id: string): Promise<IGoal>;
394
+ remove(id: string): Promise<void>;
395
+ startRun(goalId: string): Promise<IGoalRun>;
396
+ recordAction(run: IGoalRun, action: Omit<IGoalAction, 'at'>): Promise<IGoalRun>;
397
+ setWaiting(goalId: string, waiting: boolean): Promise<void>;
398
+ /** End a run, schedule the next one or close the goal, and report to the feed. */
399
+ /**
400
+ * End a run. A `quiet` run that went well is kept in the goal's history but is not posted to the
401
+ * feed, so a goal that mostly finds nothing does not fill it; a run that did not go well is posted.
402
+ */
403
+ finishRun(run: IGoalRun, outcome: TGoalRunOutcome, report: string, options?: {
404
+ readonly quiet?: boolean;
405
+ }): Promise<IGoalRun>;
406
+ /**
407
+ * After the host restarts, nothing is running: a goal it was running is due again, and an approval
408
+ * it was waiting on can no longer be answered.
409
+ */
410
+ recover(): Promise<number>;
411
+ post(item: Omit<IFeedItem, 'id' | 'at' | 'dismissed'>): Promise<IFeedItem>;
412
+ feed(limit?: number): Promise<readonly IFeedItem[]>;
413
+ feedItem(id: string): Promise<IFeedItem | undefined>;
414
+ setApproval(id: string, state: TApprovalState): Promise<IFeedItem>;
415
+ dismiss(id: string): Promise<void>;
416
+ }
417
+ //#endregion
418
+ //#region src/personal/goals/file-store.d.ts
419
+ declare function createFileGoalStore(directory: string): IGoalStore;
420
+ //#endregion
421
+ //#region src/personal/goals/memory-store.d.ts
422
+ declare function createMemoryGoalStore(): IGoalStore;
423
+ //#endregion
424
+ //#region src/personal/goals/tools.d.ts
425
+ declare const GOAL_TOOL_NAMES: {
426
+ readonly create: "GoalCreate";
427
+ readonly list: "GoalList";
428
+ readonly update: "GoalUpdate";
429
+ };
430
+ declare function renderGoal(goal: IGoal): string;
431
+ declare function createGoalTools(book: GoalBook): FunctionTool[];
432
+ declare const GOAL_INSTRUCTIONS: string;
433
+ /** What a goal run's session is told, on top of the agent's usual instructions. */
434
+ declare function goalRunInstructions(goal: IGoal): string;
435
+ //#endregion
436
+ //#region src/personal/ideas/ideas.d.ts
437
+ type TIdeaOrigin = 'owner' | 'agent';
438
+ type TIdeaStatus = 'open' | 'taken-up' | 'archived';
439
+ interface IIdea {
440
+ readonly id: string;
441
+ readonly text: string;
442
+ readonly tags: readonly string[];
443
+ readonly origin: TIdeaOrigin;
444
+ readonly status: TIdeaStatus;
445
+ /** What the idea became, such as the goal it was turned into. */
446
+ readonly takenUpAs?: string;
447
+ readonly createdAt: string;
448
+ readonly updatedAt: string;
449
+ }
450
+ /** Where ideas live; a host supplies one per principal. */
451
+ interface IIdeaStore {
452
+ list(): Promise<readonly IIdea[]>;
453
+ get(id: string): Promise<IIdea | undefined>;
454
+ put(idea: IIdea): Promise<void>;
455
+ remove(id: string): Promise<void>;
456
+ }
457
+ declare class IdeaRefusedError extends Error {
458
+ constructor(reason: string);
459
+ }
460
+ declare function createMemoryIdeaStore(): IIdeaStore;
461
+ /** Ideas in one owner-only `ideas.json`, rewritten atomically. */
462
+ declare function createFileIdeaStore(directory: string): IIdeaStore;
463
+ interface IIdeaBookOptions {
464
+ readonly store: IIdeaStore;
465
+ readonly now?: () => Date;
466
+ }
467
+ declare class IdeaBook {
468
+ private readonly store;
469
+ private readonly now;
470
+ private sequence;
471
+ constructor(options: IIdeaBookOptions);
472
+ private require;
473
+ add(input: {
474
+ readonly text: string;
475
+ readonly tags?: readonly string[];
476
+ readonly origin: TIdeaOrigin;
477
+ }): Promise<IIdea>;
478
+ /** Ideas newest first; archived ones only when asked. */
479
+ list(options?: {
480
+ readonly tag?: string;
481
+ readonly includeArchived?: boolean;
482
+ }): Promise<readonly IIdea[]>;
483
+ get(id: string): Promise<IIdea | undefined>;
484
+ /** The person took the idea up; `as` names what it became. */
485
+ takeUp(id: string, as: string): Promise<IIdea>;
486
+ archive(id: string): Promise<IIdea>;
487
+ remove(id: string): Promise<void>;
488
+ }
489
+ //#endregion
490
+ //#region src/personal/ideas/tools.d.ts
491
+ declare const IDEA_TOOL_NAMES: {
492
+ readonly add: "IdeaAdd";
493
+ readonly list: "IdeaList";
494
+ };
495
+ declare function createIdeaTools(book: IdeaBook): FunctionTool[];
496
+ 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.";
497
+ //#endregion
498
+ //#region src/personal/channels/types.d.ts
499
+ /**
500
+ * The standard channel contract: how any messenger plugs into a personal agent.
501
+ *
502
+ * An adapter turns one platform into this contract and nothing more. It declares what its platform
503
+ * can do, so the agent degrades by declaration rather than by platform name, and it reports who sent
504
+ * each message as the platform authenticated them. Everything an adapter delivers (the carrier and the
505
+ * payload) is untrusted: the hub, not the adapter, decides whether a sender is the person the agent
506
+ * works for, and an approval is only ever a structured action from that person, never text the model
507
+ * reads.
508
+ */
509
+ /** What a platform can carry, declared by its adapter. */
510
+ interface IChannelCapabilities {
511
+ /** Structured actions such as approve and decline buttons, answered as data, not text. */
512
+ readonly actions: boolean;
513
+ readonly attachments: boolean;
514
+ readonly voice: boolean;
515
+ /** The longest text one message may carry, when the platform limits it. */
516
+ readonly maxTextLength?: number;
517
+ }
518
+ /** A message a platform delivered. */
519
+ interface IChannelMessage {
520
+ /** The conversation on that platform (a chat, a thread, a direct-message channel). */
521
+ readonly conversationId: string;
522
+ /** The sender as the platform authenticated them; the hub checks it against the owner's identity. */
523
+ readonly senderId: string;
524
+ readonly text: string;
525
+ }
526
+ /** The answer to an approval request, given through a platform's structured action. */
527
+ interface IChannelApprovalAnswer {
528
+ readonly approvalId: string;
529
+ readonly approve: boolean;
530
+ readonly senderId: string;
531
+ }
532
+ /** What the hub hands an adapter when it starts it. */
533
+ interface IChannelHandler {
534
+ onMessage(message: IChannelMessage): Promise<void>;
535
+ onApprovalAnswer(answer: IChannelApprovalAnswer): Promise<void>;
536
+ }
537
+ interface IChannelApprovalRequest {
538
+ readonly conversationId: string;
539
+ readonly approvalId: string;
540
+ readonly title: string;
541
+ /** What will happen if approved: the action and where it goes. */
542
+ readonly detail: string;
543
+ }
544
+ interface IChannelAdapter {
545
+ /** A stable name for the platform, such as `fixture` or a messenger's name. */
546
+ readonly id: string;
547
+ readonly capabilities: IChannelCapabilities;
548
+ start(handler: IChannelHandler): Promise<void>;
549
+ stop(): Promise<void>;
550
+ send(conversationId: string, text: string): Promise<void>;
551
+ /** Present when `capabilities.actions` is true: ask with approve and decline actions. */
552
+ requestApproval?(request: IChannelApprovalRequest): Promise<void>;
553
+ }
554
+ //#endregion
555
+ //#region src/personal/channels/hub.d.ts
556
+ /** Runs one turn for a channel conversation and returns the agent's reply. */
557
+ type TChannelTurn = (key: {
558
+ readonly channel: string;
559
+ readonly conversationId: string;
560
+ }, text: string) => Promise<string>;
561
+ /** Answers an approval waiting in the feed. */
562
+ type TChannelApprovalAnswer = (approvalId: string, approve: boolean) => Promise<void>;
563
+ interface IChannelBinding {
564
+ readonly adapter: IChannelAdapter;
565
+ /** The owner's sender ids on this platform, verified when the channel was connected. */
566
+ readonly ownerSenderIds: readonly string[];
567
+ /** Where approvals and notices go on this platform. */
568
+ readonly notifyConversationId?: string;
569
+ }
570
+ interface IChannelHubOptions {
571
+ readonly runTurn: TChannelTurn;
572
+ readonly answerApproval: TChannelApprovalAnswer;
573
+ /** Called when a message from someone other than the owner is dropped; for the host's log. */
574
+ readonly onRefused?: (channel: string, senderId: string) => void;
575
+ }
576
+ interface IChannelHub {
577
+ connect(binding: IChannelBinding): Promise<void>;
578
+ disconnect(channelId: string): Promise<void>;
579
+ /** Tell the owner on every connected channel that an approval waits, with actions where possible. */
580
+ announceApproval(request: Omit<IChannelApprovalRequest, 'conversationId'>): Promise<void>;
581
+ /** Tell the owner something on every connected channel. */
582
+ notify(text: string): Promise<void>;
583
+ channels(): readonly {
584
+ readonly id: string;
585
+ readonly capabilities: IChannelAdapter['capabilities'];
586
+ }[];
587
+ }
588
+ /** Split text so each part fits the platform's limit, at line or word boundaries where possible. */
589
+ declare function splitForChannel(text: string, limit: number | undefined): string[];
590
+ declare function createChannelHub(options: IChannelHubOptions): IChannelHub;
591
+ //#endregion
592
+ //#region src/personal/channels/fixture.d.ts
593
+ interface IFixtureChannel extends IChannelAdapter {
594
+ /** Deliver a message as the platform would. */
595
+ deliver(conversationId: string, senderId: string, text: string): Promise<void>;
596
+ /** Press an approval's action as the platform would. */
597
+ press(approvalId: string, approve: boolean, senderId: string): Promise<void>;
598
+ readonly sent: readonly {
599
+ readonly conversationId: string;
600
+ readonly text: string;
601
+ }[];
602
+ readonly approvalRequests: readonly IChannelApprovalRequest[];
603
+ }
604
+ declare function createFixtureChannel(options?: {
605
+ readonly id?: string;
606
+ readonly capabilities?: Partial<IChannelCapabilities>;
607
+ }): IFixtureChannel;
608
+ //#endregion
609
+ //#region src/personal/spaces/spaces.d.ts
610
+ interface ISpace {
611
+ readonly id: string;
612
+ readonly name: string;
613
+ /** How the person wants the agent to work in this space, in their words. */
614
+ readonly instructions: string;
615
+ /** The tag the space's ideas carry. */
616
+ readonly tag: string;
617
+ /** Library pages pinned to the space, by page id, in pinning order. */
618
+ readonly pages: readonly string[];
619
+ readonly createdAt: string;
620
+ readonly updatedAt: string;
621
+ }
622
+ interface ISpaceStore {
623
+ list(): Promise<readonly ISpace[]>;
624
+ get(id: string): Promise<ISpace | undefined>;
625
+ put(space: ISpace): Promise<void>;
626
+ remove(id: string): Promise<void>;
627
+ }
628
+ declare class SpaceRefusedError extends Error {
629
+ constructor(reason: string);
630
+ }
631
+ /** A library page as the opening of a chat names it. */
632
+ interface ISpacePage {
633
+ readonly id: string;
634
+ readonly title: string;
635
+ }
636
+ declare function createMemorySpaceStore(): ISpaceStore;
637
+ /** Spaces in one owner-only `spaces.json`, rewritten atomically. */
638
+ declare function createFileSpaceStore(directory: string): ISpaceStore;
639
+ declare class SpaceBook {
640
+ private readonly store;
641
+ private readonly now;
642
+ private sequence;
643
+ constructor(options: {
644
+ readonly store: ISpaceStore;
645
+ readonly now?: () => Date;
646
+ });
647
+ private check;
648
+ create(input: {
649
+ readonly name: string;
650
+ readonly instructions: string;
651
+ }): Promise<ISpace>;
652
+ list(): Promise<readonly ISpace[]>;
653
+ get(id: string): Promise<ISpace | undefined>;
654
+ private existing;
655
+ /** Pin a library page; the caller has checked that the page exists. Pinning twice is a no-op. */
656
+ pin(id: string, pageId: string): Promise<ISpace>;
657
+ unpin(id: string, pageId: string): Promise<ISpace>;
658
+ update(id: string, input: {
659
+ readonly name: string;
660
+ readonly instructions: string;
661
+ }): Promise<ISpace>;
662
+ remove(id: string): Promise<void>;
663
+ /**
664
+ * The first message of a chat started in the space: the person's own instructions, named as such,
665
+ * and the pinned pages that still exist, by title and id so the agent can read them.
666
+ */
667
+ opening(space: ISpace, pages?: readonly ISpacePage[]): string;
668
+ }
669
+ //#endregion
670
+ //#region src/personal/connectors/types.d.ts
671
+ /**
672
+ * Connectors: external services the person connected once (mail, calendar, files, chat, notes, ...)
673
+ * that the agent reads on demand and keeps in sync. A connector is data — a kind, an endpoint and the
674
+ * person's decisions about its tools — and a protocol port reaches it. Nothing here holds a
675
+ * credential or knows a protocol.
676
+ */
677
+ /** What a connector is for. A tag the person and the agent read, not a code path. */
678
+ type TConnectorKind = 'mail' | 'calendar' | 'files' | 'chat' | 'notes' | 'other';
679
+ declare const CONNECTOR_KINDS: readonly TConnectorKind[];
680
+ /** The person's own decision about one tool, over what the service claims about it. */
681
+ type TToolDecision = 'read' | 'write' | 'blocked';
682
+ /** What a tool is treated as: reading is allowed, writing is held for the person, blocked is never called. */
683
+ type TToolAccess = TToolDecision;
684
+ interface IConnector {
685
+ /** `connector-` and a slug; unique within one person's connectors. */
686
+ readonly id: string;
687
+ readonly title: string;
688
+ readonly kind: TConnectorKind;
689
+ /** Which protocol adapter reaches it, such as `mcp`. */
690
+ readonly protocol: string;
691
+ /** Where the service is reached: an `https` address that carries no credential. */
692
+ readonly endpoint: string;
693
+ /**
694
+ * 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.
696
+ */
697
+ readonly oauth?: {
698
+ readonly clientId?: string;
699
+ readonly scopes?: readonly string[];
700
+ };
701
+ /** The person's decisions, by tool name. A tool without one is sorted by what the service claims. */
702
+ readonly decisions: Readonly<Record<string, TToolDecision>>;
703
+ readonly createdAt: string;
704
+ readonly updatedAt: string;
705
+ }
706
+ /** What a service says about a tool's effect: a claim, never a guarantee. */
707
+ interface IConnectorToolHints {
708
+ readonly readOnly?: boolean;
709
+ readonly destructive?: boolean;
710
+ readonly idempotent?: boolean;
711
+ readonly openWorld?: boolean;
712
+ }
713
+ /** A tool a connected service offers, as the service declared it. */
714
+ interface IConnectorToolInfo {
715
+ readonly name: string;
716
+ readonly description?: string;
717
+ /** The input the tool takes, JSON-Schema-shaped. */
718
+ readonly inputSchema: Readonly<Record<string, unknown>>;
719
+ readonly hints?: IConnectorToolHints;
720
+ }
721
+ /**
722
+ * Where the person stands with a connector, as a fixed word:
723
+ * `not-connected`, `connecting` (the person has to finish signing in), `connected`,
724
+ * `needs-sign-in` (a credential was kept but can no longer be used) or `failed`.
725
+ */
726
+ type TConnectorState = 'not-connected' | 'connecting' | 'connected' | 'needs-sign-in' | 'failed';
727
+ interface IConnectorStatus {
728
+ readonly state: TConnectorState;
729
+ /** Why a sign-in or a connection failed, as a fixed word; never text from a service or a token. */
730
+ readonly reason?: string;
731
+ /** While connecting: where the person's browser goes to consent. */
732
+ readonly authorizationUrl?: string;
733
+ /** While connecting: the address the consent returns to, which a pre-registered client must list. */
734
+ readonly redirectUri?: string;
735
+ /**
736
+ * While connected: the scopes the service says it granted, as scope words. What the person
737
+ * consented to is this, so it is shown as the authoritative permission; never a token or derived
738
+ * from one.
739
+ */
740
+ readonly scope?: string;
741
+ }
742
+ /** Where the person's browser reaches this agent; the consent returns there. */
743
+ interface ISignInContext {
744
+ readonly origin: string;
745
+ }
746
+ type TRevocation = 'revoked' | 'partial' | 'unsupported' | 'failed' | 'not-attempted';
747
+ interface IDisconnectOutcome {
748
+ /** Whether a credential was kept before. It is gone now whatever the service answered. */
749
+ readonly removed: boolean;
750
+ readonly revocation: TRevocation;
751
+ }
752
+ interface IConnectorCallResult {
753
+ /** What the service returned, as text. It is data from the service, never instructions. */
754
+ readonly text: string;
755
+ readonly isError: boolean;
756
+ }
757
+ /**
758
+ * One protocol's way to reach a service. The composition root supplies it, because reaching a
759
+ * service needs a host (network, files, a browser sign-in), and the pack stays neutral.
760
+ */
761
+ interface IConnectorProtocol {
762
+ readonly id: string;
763
+ status(connector: IConnector): Promise<IConnectorStatus>;
764
+ /**
765
+ * Start the person's sign-in. Returns at once with where their browser goes; the sign-in finishes
766
+ * on its own when the browser comes back, and `status` then says `connected` or `failed`.
767
+ */
768
+ signIn(connector: IConnector, context: ISignInContext): Promise<IConnectorStatus>;
769
+ /** Delete the credential first, then ask the service to revoke it. */
770
+ signOut(connector: IConnector): Promise<IDisconnectOutcome>;
771
+ tools(connector: IConnector): Promise<readonly IConnectorToolInfo[]>;
772
+ call(connector: IConnector, tool: string, args: Readonly<Record<string, unknown>>, options?: {
773
+ readonly signal?: AbortSignal;
774
+ }): Promise<IConnectorCallResult>;
775
+ /** Let go of what is held for a connector that is being removed. */
776
+ forget(connector: IConnector): Promise<void>;
777
+ close(): Promise<void>;
778
+ }
779
+ //#endregion
780
+ //#region src/personal/connectors/book.d.ts
781
+ interface IConnectorStore {
782
+ list(): Promise<readonly IConnector[]>;
783
+ get(id: string): Promise<IConnector | undefined>;
784
+ put(connector: IConnector): Promise<void>;
785
+ remove(id: string): Promise<void>;
786
+ }
787
+ declare class ConnectorRefusedError extends Error {
788
+ constructor(reason: string);
789
+ }
790
+ declare function createMemoryConnectorStore(): IConnectorStore;
791
+ /** Connectors in one owner-only `connectors.json`, rewritten atomically. */
792
+ declare function createFileConnectorStore(directory: string): IConnectorStore;
793
+ interface ICreateConnectorInput {
794
+ readonly title: string;
795
+ readonly kind: TConnectorKind;
796
+ readonly protocol: string;
797
+ readonly endpoint: string;
798
+ readonly oauth?: {
799
+ readonly clientId?: string;
800
+ readonly scopes?: readonly string[];
801
+ };
802
+ }
803
+ declare class ConnectorBook {
804
+ private readonly store;
805
+ private readonly now;
806
+ private sequence;
807
+ constructor(options: {
808
+ readonly store: IConnectorStore;
809
+ readonly now?: () => Date;
810
+ });
811
+ create(input: ICreateConnectorInput): Promise<IConnector>;
812
+ private checkOAuth;
813
+ list(): Promise<readonly IConnector[]>;
814
+ get(id: string): Promise<IConnector | undefined>;
815
+ existing(id: string): Promise<IConnector>;
816
+ /** Record the person's decision about one tool, or clear it with `undefined`. */
817
+ decide(id: string, tool: string, decision: TToolDecision | undefined): Promise<IConnector>;
818
+ remove(id: string): Promise<void>;
819
+ }
820
+ //#endregion
821
+ //#region src/personal/connectors/registry.d.ts
822
+ interface IConnectorToolView extends IConnectorToolInfo {
823
+ /** What the tool is treated as. */
824
+ readonly access: TToolAccess;
825
+ /** The person's own decision, when there is one. */
826
+ readonly decision?: TToolDecision;
827
+ }
828
+ interface IConnectorView {
829
+ readonly connector: IConnector;
830
+ readonly status: IConnectorStatus;
831
+ /** The tools a connected service offers; absent while it is not connected or cannot be reached. */
832
+ readonly tools?: readonly IConnectorToolView[];
833
+ }
834
+ interface IConnectorRegistryOptions {
835
+ readonly book: ConnectorBook;
836
+ readonly protocols: readonly IConnectorProtocol[];
837
+ /** How long a service's tool list is reused; a new decision or a miss refreshes it sooner. */
838
+ readonly toolCacheMs?: number;
839
+ readonly now?: () => number;
840
+ }
841
+ /**
842
+ * What a tool is treated as: the person's decision first, else the service's read-only claim, else a
843
+ * write. A decision that is present but not one of the three words (a hand-edited or damaged file)
844
+ * is something the person said that cannot be read, so the tool is blocked rather than guessed at.
845
+ */
846
+ declare function classifyTool(connector: IConnector, tool: IConnectorToolInfo): TToolAccess;
847
+ declare class ConnectorRegistry {
848
+ private readonly book;
849
+ private readonly protocols;
850
+ private readonly cacheMs;
851
+ private readonly now;
852
+ private readonly cache;
853
+ private readonly reads;
854
+ constructor(options: IConnectorRegistryOptions);
855
+ private protocolOf;
856
+ private toolsOf;
857
+ private viewTools;
858
+ view(id: string, options?: {
859
+ readonly refresh?: boolean;
860
+ }): Promise<IConnectorView>;
861
+ list(): Promise<readonly IConnectorView[]>;
862
+ /** Start the person's sign-in; the answer says where their browser goes. */
863
+ signIn(id: string, context: ISignInContext): Promise<IConnectorStatus>;
864
+ disconnect(id: string): Promise<IDisconnectOutcome>;
865
+ /** Disconnect and forget a connector: the credential is deleted before anything else. */
866
+ remove(id: string): Promise<IDisconnectOutcome>;
867
+ decide(id: string, tool: string, decision: TToolDecision | undefined): Promise<IConnector>;
868
+ /** One connector's tools as the model should see them. */
869
+ describe(id: string): Promise<IConnectorView>;
870
+ private notReady;
871
+ private resolve;
872
+ /**
873
+ * How many reads on a connector worked and how many did not (refused, errored or reported as an
874
+ * error by the service), counted since this agent started. A caller that wants to know whether
875
+ * a stretch of work could read compares the counts before and after.
876
+ */
877
+ readCounts(id: string): {
878
+ readonly succeeded: number;
879
+ readonly failed: number;
880
+ };
881
+ private noteRead;
882
+ /** Call a tool that only reads. A tool that writes is refused here, whatever the caller says it is. */
883
+ read(id: string, tool: string, args: Readonly<Record<string, unknown>>, signal?: AbortSignal): Promise<IConnectorCallResult>;
884
+ /** 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>;
886
+ close(): Promise<void>;
887
+ }
888
+ //#endregion
889
+ //#region src/personal/connectors/tools.d.ts
890
+ declare const CONNECTOR_TOOL_NAMES: {
891
+ readonly list: "ConnectorList";
892
+ readonly read: "ConnectorRead";
893
+ readonly act: "ConnectorAct";
894
+ readonly keep: "ConnectorKeep";
895
+ };
896
+ declare function createConnectorTools(registry: ConnectorRegistry): FunctionTool[];
897
+ declare const CONNECTOR_INSTRUCTIONS: string;
898
+ //#endregion
899
+ //#region src/personal/connectors/keep.d.ts
900
+ /** Where a claim pulled from a connector of this kind says it came from. */
901
+ declare function originOfConnector(kind: TConnectorKind): TClaimOrigin;
902
+ /** The reference a claim carries: the connector, then the item it was read from. */
903
+ declare function connectorReference(connectorId: string, item?: string): string;
904
+ /** How many claims in the library came from this connector. */
905
+ declare function countPulled(wiki: KnowledgeWiki, connectorId: string): Promise<number>;
906
+ /** Remove every claim pulled from this connector, and nothing the person or another source said. */
907
+ declare function forgetPulled(wiki: KnowledgeWiki, connectorId: string): Promise<number>;
908
+ /**
909
+ * The tool that files a fact read from a connector into the library. It always files with the
910
+ * origin and reference the connector's kind and id decide, so what a sync keeps can be told from
911
+ * what the person said and removed with the connection, and it only adds: a changed fact is another
912
+ * claim beside the old one, so content read from a service never rewrites what the person said.
913
+ */
914
+ declare function createConnectorKeepTool(options: {
915
+ readonly book: ConnectorBook;
916
+ readonly wiki: KnowledgeWiki;
917
+ }): FunctionTool;
918
+ //#endregion
919
+ //#region src/personal/connectors/sync.d.ts
920
+ /** How often a sync may run: not more often than a run is worth, not less often than weekly. */
921
+ declare const SYNC_MIN_MINUTES = 15;
922
+ declare const SYNC_MAX_MINUTES: number;
923
+ /**
924
+ * 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
927
+ * what is allowed, not of what is withheld: a tool added later is then not offered until it is named.
928
+ */
929
+ declare function syncRunTools(): string[];
930
+ /** What a sync run is asked, as the goal's own text: short, and shown to the person with the goal. */
931
+ 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. */
933
+ declare function syncRunInstructions(connector: IConnector, since: string | undefined): string;
934
+ interface IConnectorSyncStatus {
935
+ readonly goalId: string;
936
+ readonly everyMinutes: number;
937
+ readonly status: IGoal['status'];
938
+ readonly lastRunAt?: string;
939
+ readonly nextRunAt?: string;
940
+ }
941
+ /**
942
+ * The goals that keep connectors in sync: one per connector, found by the connector it names. `halt`
943
+ * ends a run that is in progress, which a goal cannot be removed during.
944
+ */
945
+ declare class ConnectorSync {
946
+ private readonly goals;
947
+ private readonly halt?;
948
+ constructor(goals: GoalBook, halt?: ((goalId: string) => Promise<void>) | undefined);
949
+ private goalOf;
950
+ status(connectorId: string): Promise<IConnectorSyncStatus | undefined>;
951
+ /** Turn sync on, or change how often it runs; a new sync is due at once, a changed one keeps its place. */
952
+ enable(connector: IConnector, everyMinutes: number): Promise<IConnectorSyncStatus>;
953
+ /** Turn sync off. The reports and runs it made are gone with the goal; what it kept stays in the library. */
954
+ disable(connectorId: string): Promise<boolean>;
955
+ }
956
+ //#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 };
253
958
  //# sourceMappingURL=index.d.ts.map