@animalabs/agent-framework 0.26.2 → 0.27.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.
- package/README.md +56 -6
- package/dist/src/agent.d.ts +263 -22
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +531 -54
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +1 -2
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/auto-continue.d.ts +33 -0
- package/dist/src/auto-continue.d.ts.map +1 -0
- package/dist/src/auto-continue.js +35 -0
- package/dist/src/auto-continue.js.map +1 -0
- package/dist/src/code-execution/isolate/scripts.d.ts +11 -0
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/scripts.js +5 -1
- package/dist/src/code-execution/isolate/scripts.js.map +1 -1
- package/dist/src/framework.d.ts +759 -129
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +3482 -928
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +309 -46
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +2117 -395
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/gate/index.d.ts +2 -2
- package/dist/src/gate/index.d.ts.map +1 -1
- package/dist/src/gate/index.js +1 -1
- package/dist/src/gate/index.js.map +1 -1
- package/dist/src/gate/recipe-reconcile.d.ts +103 -0
- package/dist/src/gate/recipe-reconcile.d.ts.map +1 -0
- package/dist/src/gate/recipe-reconcile.js +325 -0
- package/dist/src/gate/recipe-reconcile.js.map +1 -0
- package/dist/src/gate/types.d.ts +68 -8
- package/dist/src/gate/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +6 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts +433 -113
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +1152 -434
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/conversation-router.d.ts +16 -8
- package/dist/src/mcpl/conversation-router.d.ts.map +1 -1
- package/dist/src/mcpl/conversation-router.js +29 -15
- package/dist/src/mcpl/conversation-router.js.map +1 -1
- package/dist/src/mcpl/convert-block.d.ts.map +1 -1
- package/dist/src/mcpl/convert-block.js +14 -2
- package/dist/src/mcpl/convert-block.js.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts +7 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.js +32 -7
- package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
- package/dist/src/mcpl/index.d.ts +5 -1
- package/dist/src/mcpl/index.d.ts.map +1 -1
- package/dist/src/mcpl/index.js +4 -0
- package/dist/src/mcpl/index.js.map +1 -1
- package/dist/src/mcpl/inference-router.d.ts +14 -2
- package/dist/src/mcpl/inference-router.d.ts.map +1 -1
- package/dist/src/mcpl/inference-router.js +73 -28
- package/dist/src/mcpl/inference-router.js.map +1 -1
- package/dist/src/mcpl/prose-grammar.d.ts +4 -0
- package/dist/src/mcpl/prose-grammar.d.ts.map +1 -1
- package/dist/src/mcpl/prose-grammar.js +6 -0
- package/dist/src/mcpl/prose-grammar.js.map +1 -1
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
- package/dist/src/mcpl/protocol-family.js +3 -0
- package/dist/src/mcpl/protocol-family.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +20 -2
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +33 -11
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts +63 -42
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
- package/dist/src/mcpl/reference-fetcher.js +177 -145
- package/dist/src/mcpl/reference-fetcher.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +380 -46
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +736 -77
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +82 -3
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +132 -7
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.d.ts +11 -0
- package/dist/src/mcpl/tool-lifecycle.d.ts.map +1 -1
- package/dist/src/mcpl/tool-lifecycle.js +21 -0
- package/dist/src/mcpl/tool-lifecycle.js.map +1 -1
- package/dist/src/mcpl/tool-presence.d.ts +259 -0
- package/dist/src/mcpl/tool-presence.d.ts.map +1 -0
- package/dist/src/mcpl/tool-presence.js +628 -0
- package/dist/src/mcpl/tool-presence.js.map +1 -0
- package/dist/src/mcpl/tool-result-normalize.d.ts +9 -3
- package/dist/src/mcpl/tool-result-normalize.d.ts.map +1 -1
- package/dist/src/mcpl/tool-result-normalize.js +14 -6
- package/dist/src/mcpl/tool-result-normalize.js.map +1 -1
- package/dist/src/mcpl/tool-signature.d.ts +39 -0
- package/dist/src/mcpl/tool-signature.d.ts.map +1 -0
- package/dist/src/mcpl/tool-signature.js +292 -0
- package/dist/src/mcpl/tool-signature.js.map +1 -0
- package/dist/src/mcpl/toolset-host.d.ts +200 -0
- package/dist/src/mcpl/toolset-host.d.ts.map +1 -0
- package/dist/src/mcpl/toolset-host.js +621 -0
- package/dist/src/mcpl/toolset-host.js.map +1 -0
- package/dist/src/mcpl/toolsets-module.d.ts +80 -0
- package/dist/src/mcpl/toolsets-module.d.ts.map +1 -0
- package/dist/src/mcpl/toolsets-module.js +431 -0
- package/dist/src/mcpl/toolsets-module.js.map +1 -0
- package/dist/src/mcpl/transport.d.ts +2 -2
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +3 -2
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +21 -1
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/mcpl/visible-content.d.ts +7 -9
- package/dist/src/mcpl/visible-content.d.ts.map +1 -1
- package/dist/src/mcpl/visible-content.js +21 -9
- package/dist/src/mcpl/visible-content.js.map +1 -1
- package/dist/src/module-registry.d.ts +23 -8
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +68 -15
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/discord/index.js +1 -1
- package/dist/src/modules/discord/index.js.map +1 -1
- package/dist/src/modules/history/index.d.ts +2 -1
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +51 -17
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/history/semantic.d.ts +108 -6
- package/dist/src/modules/history/semantic.d.ts.map +1 -1
- package/dist/src/modules/history/semantic.js +273 -57
- package/dist/src/modules/history/semantic.js.map +1 -1
- package/dist/src/modules/workspace/direct-write.d.ts +181 -0
- package/dist/src/modules/workspace/direct-write.d.ts.map +1 -0
- package/dist/src/modules/workspace/direct-write.js +384 -0
- package/dist/src/modules/workspace/direct-write.js.map +1 -0
- package/dist/src/modules/workspace/edit-text.d.ts +26 -12
- package/dist/src/modules/workspace/edit-text.d.ts.map +1 -1
- package/dist/src/modules/workspace/edit-text.js +58 -28
- package/dist/src/modules/workspace/edit-text.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts +10 -0
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +1 -1
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +246 -27
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +1216 -236
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/read-page.d.ts +41 -0
- package/dist/src/modules/workspace/read-page.d.ts.map +1 -0
- package/dist/src/modules/workspace/read-page.js +213 -0
- package/dist/src/modules/workspace/read-page.js.map +1 -0
- package/dist/src/modules/workspace/result-text.d.ts +67 -0
- package/dist/src/modules/workspace/result-text.d.ts.map +1 -0
- package/dist/src/modules/workspace/result-text.js +94 -0
- package/dist/src/modules/workspace/result-text.js.map +1 -0
- package/dist/src/modules/workspace/text.d.ts +29 -12
- package/dist/src/modules/workspace/text.d.ts.map +1 -1
- package/dist/src/modules/workspace/text.js +35 -33
- package/dist/src/modules/workspace/text.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +41 -17
- package/dist/src/modules/workspace/types.d.ts.map +1 -1
- package/dist/src/modules/workspace/types.js.map +1 -1
- package/dist/src/sent-rows.d.ts +59 -0
- package/dist/src/sent-rows.d.ts.map +1 -0
- package/dist/src/sent-rows.js +145 -0
- package/dist/src/sent-rows.js.map +1 -0
- package/dist/src/silent-heartbeat.d.ts +17 -10
- package/dist/src/silent-heartbeat.d.ts.map +1 -1
- package/dist/src/silent-heartbeat.js.map +1 -1
- package/dist/src/stable-hash.d.ts +3 -0
- package/dist/src/stable-hash.d.ts.map +1 -0
- package/dist/src/stable-hash.js +15 -0
- package/dist/src/stable-hash.js.map +1 -0
- package/dist/src/stored-injections.d.ts +99 -0
- package/dist/src/stored-injections.d.ts.map +1 -0
- package/dist/src/stored-injections.js +106 -0
- package/dist/src/stored-injections.js.map +1 -0
- package/dist/src/text-as-stored.d.ts +4 -3
- package/dist/src/text-as-stored.d.ts.map +1 -1
- package/dist/src/text-as-stored.js +4 -3
- package/dist/src/text-as-stored.js.map +1 -1
- package/dist/src/thinking-drops.d.ts +81 -0
- package/dist/src/thinking-drops.d.ts.map +1 -0
- package/dist/src/thinking-drops.js +103 -0
- package/dist/src/thinking-drops.js.map +1 -0
- package/dist/src/tool-image-ledger.d.ts +9 -8
- package/dist/src/tool-image-ledger.d.ts.map +1 -1
- package/dist/src/tool-image-ledger.js +9 -8
- package/dist/src/tool-image-ledger.js.map +1 -1
- package/dist/src/tool-presentation.d.ts.map +1 -1
- package/dist/src/tool-presentation.js +3 -1
- package/dist/src/tool-presentation.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +4 -2
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +21 -6
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tool-result-history.d.ts +176 -24
- package/dist/src/tool-result-history.d.ts.map +1 -1
- package/dist/src/tool-result-history.js +411 -91
- package/dist/src/tool-result-history.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +17 -9
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +84 -37
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/types/agent.d.ts +186 -7
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +15 -1
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +24 -3
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +90 -7
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +57 -2
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/agent.ts +593 -60
- package/src/api/server.ts +1 -2
- package/src/auto-continue.ts +42 -0
- package/src/code-execution/isolate/scripts.ts +11 -3
- package/src/framework.ts +3601 -967
- package/src/gate/event-gate.ts +2315 -389
- package/src/gate/index.ts +2 -1
- package/src/gate/recipe-reconcile.ts +355 -0
- package/src/gate/types.ts +70 -8
- package/src/index.ts +7 -4
- package/src/mcpl/channel-registry.ts +1220 -467
- package/src/mcpl/conversation-router.ts +34 -16
- package/src/mcpl/convert-block.ts +14 -1
- package/src/mcpl/hook-orchestrator.ts +33 -6
- package/src/mcpl/index.ts +6 -1
- package/src/mcpl/inference-router.ts +79 -34
- package/src/mcpl/prose-grammar.ts +7 -0
- package/src/mcpl/protocol-family.ts +2 -0
- package/src/mcpl/push-coalescer.ts +51 -13
- package/src/mcpl/reference-fetcher.ts +201 -162
- package/src/mcpl/references.ts +851 -77
- package/src/mcpl/server-connection.ts +145 -7
- package/src/mcpl/tool-lifecycle.ts +21 -0
- package/src/mcpl/tool-presence.ts +650 -0
- package/src/mcpl/tool-result-normalize.ts +18 -6
- package/src/mcpl/tool-signature.ts +285 -0
- package/src/mcpl/toolset-host.ts +637 -0
- package/src/mcpl/toolsets-module.ts +451 -0
- package/src/mcpl/transport.ts +3 -2
- package/src/mcpl/types.ts +22 -1
- package/src/mcpl/visible-content.ts +22 -9
- package/src/module-registry.ts +77 -24
- package/src/modules/discord/index.ts +1 -1
- package/src/modules/history/index.ts +48 -18
- package/src/modules/history/semantic.ts +308 -54
- package/src/modules/workspace/direct-write.ts +425 -0
- package/src/modules/workspace/edit-text.ts +82 -35
- package/src/modules/workspace/effects.ts +1 -1
- package/src/modules/workspace/index.ts +1274 -241
- package/src/modules/workspace/read-page.ts +222 -0
- package/src/modules/workspace/result-text.ts +119 -0
- package/src/modules/workspace/text.ts +58 -32
- package/src/modules/workspace/types.ts +41 -17
- package/src/sent-rows.ts +162 -0
- package/src/silent-heartbeat.ts +17 -10
- package/src/stable-hash.ts +14 -0
- package/src/stored-injections.ts +131 -0
- package/src/text-as-stored.ts +4 -3
- package/src/thinking-drops.ts +141 -0
- package/src/tool-image-ledger.ts +9 -8
- package/src/tool-presentation.ts +3 -1
- package/src/tool-result-guard.ts +19 -6
- package/src/tool-result-history.ts +471 -90
- package/src/tune-out/coordinator.ts +80 -37
- package/src/types/agent.ts +189 -7
- package/src/types/events.ts +15 -1
- package/src/types/framework.ts +21 -3
- package/src/types/module.ts +86 -7
- package/src/types/trace.ts +58 -2
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCPL RFC-014 (tool presence, toolsets and surfaces): one server's tool
|
|
3
|
+
* presence as the host keeps it.
|
|
4
|
+
*
|
|
5
|
+
* The server's tool list stays its whole truth (RFC §2 principle 1); hints say
|
|
6
|
+
* which tools are static (the API tool list, as before) and which are dynamic
|
|
7
|
+
* (announced in the conversation as they come and go, and called through the
|
|
8
|
+
* host's `act`). Per server this keeps:
|
|
9
|
+
*
|
|
10
|
+
* - the tool definitions (tools/list) and the toolset declarations (manifest);
|
|
11
|
+
* - which declared toolsets and instances are open (toolsets/open results,
|
|
12
|
+
* toolsets/list, hint `toolsets` entries), and which undeclared groups the
|
|
13
|
+
* host opened itself (RFC §5.4: the server is never told);
|
|
14
|
+
* - the server's visibility statements per instance, and definition
|
|
15
|
+
* overrides, from hint changes applied in `rev` order, each at most once.
|
|
16
|
+
* One apply path serves every carrier: a call's, an open's or a close's
|
|
17
|
+
* result, a push's `hints`, a standalone `tools/hints`. `tools/list`
|
|
18
|
+
* (`mcpl/rev`) and `toolsets/list` are statements later changes build on;
|
|
19
|
+
* - which definitions the model has been shown, so a tool's first sentence
|
|
20
|
+
* is said once.
|
|
21
|
+
*
|
|
22
|
+
* Every mutation is bracketed by view() snapshots, and diff() turns the
|
|
23
|
+
* difference into what the model reads. Nothing here does I/O: the
|
|
24
|
+
* controller (toolset-host.ts) feeds it what the connection read.
|
|
25
|
+
*
|
|
26
|
+
* Ported from mcpl-cc-bridge's presence.ts, the reference host.
|
|
27
|
+
*/
|
|
28
|
+
import { type HintedTool } from './tool-signature.js';
|
|
29
|
+
export interface ToolsetDecl {
|
|
30
|
+
title?: string;
|
|
31
|
+
summary?: string;
|
|
32
|
+
default?: 'open' | 'closed';
|
|
33
|
+
instances?: boolean;
|
|
34
|
+
options?: unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface Suggestion {
|
|
37
|
+
toolset: string;
|
|
38
|
+
instance?: string;
|
|
39
|
+
action: 'open' | 'close';
|
|
40
|
+
reason: string;
|
|
41
|
+
}
|
|
42
|
+
export interface OpenRecord {
|
|
43
|
+
toolset: string;
|
|
44
|
+
instance?: string;
|
|
45
|
+
title?: string;
|
|
46
|
+
}
|
|
47
|
+
/** RFC-014 §5.3: an instance that ended other than by a toolsets/close. */
|
|
48
|
+
export interface Ended {
|
|
49
|
+
id?: string;
|
|
50
|
+
toolset: string;
|
|
51
|
+
instance?: string;
|
|
52
|
+
reason: string;
|
|
53
|
+
}
|
|
54
|
+
export type Presence = 'static' | 'dynamic';
|
|
55
|
+
/** The names of the host's meta-tools, as the model calls them. */
|
|
56
|
+
export interface MetaToolNames {
|
|
57
|
+
open: string;
|
|
58
|
+
act: string;
|
|
59
|
+
look: string;
|
|
60
|
+
close: string;
|
|
61
|
+
}
|
|
62
|
+
/** Toolset-less dynamic tools live under this key: always "open", visible per the server. */
|
|
63
|
+
export declare const NO_TOOLSET = "";
|
|
64
|
+
export declare const keyOf: (toolset: string, instance?: string) => string;
|
|
65
|
+
export declare const splitKey: (key: string) => {
|
|
66
|
+
toolset: string;
|
|
67
|
+
instance?: string;
|
|
68
|
+
};
|
|
69
|
+
interface Entry {
|
|
70
|
+
title?: string;
|
|
71
|
+
tools: Map<string, HintedTool>;
|
|
72
|
+
}
|
|
73
|
+
/** What the model may use right now: per key, the visible tools. Open-but-empty keys are present with no tools. */
|
|
74
|
+
export type View = Map<string, Entry>;
|
|
75
|
+
export interface Change {
|
|
76
|
+
key: string;
|
|
77
|
+
toolset: string;
|
|
78
|
+
instance?: string;
|
|
79
|
+
title?: string;
|
|
80
|
+
opened: boolean;
|
|
81
|
+
closed: boolean;
|
|
82
|
+
retitled: boolean;
|
|
83
|
+
appeared: HintedTool[];
|
|
84
|
+
gone: string[];
|
|
85
|
+
redefined: HintedTool[];
|
|
86
|
+
/** The visible tools after the change. */
|
|
87
|
+
now: HintedTool[];
|
|
88
|
+
}
|
|
89
|
+
export interface ChangeSet {
|
|
90
|
+
changes: Change[];
|
|
91
|
+
suggest: Suggestion[];
|
|
92
|
+
notes: string[];
|
|
93
|
+
}
|
|
94
|
+
export declare const emptyChange: () => ChangeSet;
|
|
95
|
+
export declare const isEmptyChange: (c: ChangeSet) => boolean;
|
|
96
|
+
export declare const joinChanges: (...sets: ChangeSet[]) => ChangeSet;
|
|
97
|
+
/**
|
|
98
|
+
* RFC-014 §6.1: revs on a connection are consecutive (1, 2, 3 …), and changes
|
|
99
|
+
* apply in rev order, which on stdio and WebSocket is arrival order.
|
|
100
|
+
* applied: a rev above the last, applied; `skipped` when it isn't exactly
|
|
101
|
+
* the last + 1 (a message was lost unread): recover.
|
|
102
|
+
* behind: at or below the last, not applied: recover.
|
|
103
|
+
*/
|
|
104
|
+
export interface ApplyOutcome {
|
|
105
|
+
applied: boolean;
|
|
106
|
+
skipped: boolean;
|
|
107
|
+
behind: boolean;
|
|
108
|
+
suggest: Suggestion[];
|
|
109
|
+
}
|
|
110
|
+
/** What a hint `definition` may change (RFC §6.1): everything else stays the listed tool's. */
|
|
111
|
+
interface DefOverride {
|
|
112
|
+
description?: string;
|
|
113
|
+
inputSchema?: Record<string, unknown>;
|
|
114
|
+
annotations?: Record<string, unknown>;
|
|
115
|
+
}
|
|
116
|
+
/** The fields a hint definition may change (RFC §6.1); `name` and all of `_meta` are ignored. */
|
|
117
|
+
export declare function overrideOf(d: Record<string, unknown>): DefOverride;
|
|
118
|
+
export declare class ToolPresence {
|
|
119
|
+
readonly server: string;
|
|
120
|
+
/** The meta-tools' names, for the hints rendered text gives. */
|
|
121
|
+
readonly names: MetaToolNames;
|
|
122
|
+
/** The host's tool policy (enabledTools/disabledTools): a tool it refuses is as if unlisted. */
|
|
123
|
+
private readonly allowed;
|
|
124
|
+
/** How a static tool is named in the API tool list, for `look`. */
|
|
125
|
+
private readonly listedName;
|
|
126
|
+
/** Hints are in effect on the current connection: the host advertised toolHints and the server did too. */
|
|
127
|
+
active: boolean;
|
|
128
|
+
declared: Record<string, ToolsetDecl>;
|
|
129
|
+
surface: {
|
|
130
|
+
title?: string;
|
|
131
|
+
summary?: string;
|
|
132
|
+
} | null;
|
|
133
|
+
/** The last rev read on this connection (RFC §6.1); 0 at each connect. */
|
|
134
|
+
rev: number;
|
|
135
|
+
private tools;
|
|
136
|
+
private open;
|
|
137
|
+
private groups;
|
|
138
|
+
private visible;
|
|
139
|
+
/** Definition overrides from hints: per key (an instance's own, or a toolset's), per tool. */
|
|
140
|
+
private defs;
|
|
141
|
+
/** `ended` ids told to the agent: once per id, across reconnects (RFC §5.3). */
|
|
142
|
+
private toldEnded;
|
|
143
|
+
private pendingMoves;
|
|
144
|
+
private moved;
|
|
145
|
+
/** Digests of definitions the model has been shown with their first sentence. */
|
|
146
|
+
readonly shown: Set<string>;
|
|
147
|
+
constructor(server: string,
|
|
148
|
+
/** The meta-tools' names, for the hints rendered text gives. */
|
|
149
|
+
names: MetaToolNames,
|
|
150
|
+
/** The host's tool policy (enabledTools/disabledTools): a tool it refuses is as if unlisted. */
|
|
151
|
+
allowed?: (tool: string) => boolean,
|
|
152
|
+
/** How a static tool is named in the API tool list, for `look`. */
|
|
153
|
+
listedName?: (tool: string) => string);
|
|
154
|
+
/** A new connection: revs start over; hints count only when both sides advertised toolHints. */
|
|
155
|
+
beginConnection(mcpl: Record<string, unknown> | null | undefined, hostHints: boolean): void;
|
|
156
|
+
/** Toolset declarations and the surface hint, from initialize or a manifest re-fetch. */
|
|
157
|
+
setManifest(mcpl: Record<string, unknown> | null | undefined): void;
|
|
158
|
+
/** RFC §5.1: a server that withdraws toolHints is hint-less from then on: every tool static, nothing dynamic presented. */
|
|
159
|
+
deactivate(): void;
|
|
160
|
+
/** tools/list: every definition, visible or not (RFC §4.1). A tool the host's policy refuses is left out. */
|
|
161
|
+
setTools(list: HintedTool[]): void;
|
|
162
|
+
/** Whether the meta-tools speak for this server: hints in effect and something dynamic. */
|
|
163
|
+
get presents(): boolean;
|
|
164
|
+
get allTools(): HintedTool[];
|
|
165
|
+
tool(name: string): HintedTool | undefined;
|
|
166
|
+
toolsetOf(name: string): string | undefined;
|
|
167
|
+
/** static unless hinted dynamic; a toolset wins over any "static" (RFC §4.1); a move applies only at a boundary (applyMoves). */
|
|
168
|
+
presenceOf(name: string): Presence;
|
|
169
|
+
isDeclared(toolset: string): boolean;
|
|
170
|
+
/** Undeclared toolset names the server's tools are tagged with (RFC §5.4). */
|
|
171
|
+
get undeclaredGroups(): string[];
|
|
172
|
+
openRecords(toolset?: string): OpenRecord[];
|
|
173
|
+
isOpen(toolset: string, instance?: string): boolean;
|
|
174
|
+
get openGroups(): string[];
|
|
175
|
+
/**
|
|
176
|
+
* The definition the model sees, and the host checks arguments against, for
|
|
177
|
+
* `name` in `key`: the instance's own (a hint definition with `instance`),
|
|
178
|
+
* else the toolset's (one without), else the listed one (RFC §6.1).
|
|
179
|
+
*/
|
|
180
|
+
defOf(key: string, name: string): HintedTool;
|
|
181
|
+
view(): View;
|
|
182
|
+
diff(before: View, after: View): ChangeSet;
|
|
183
|
+
/** Apply a HintChanges (RFC §6.1) from any of its carriers, as it is read (see ApplyOutcome). */
|
|
184
|
+
apply(h: unknown): ApplyOutcome;
|
|
185
|
+
/**
|
|
186
|
+
* tools/list's `_meta["mcpl/rev"]` (RFC §4.1): the last rev the server had
|
|
187
|
+
* sent when it wrote the list, which takes none itself. Read in order it
|
|
188
|
+
* equals the last rev read; a higher one means a message was lost (true).
|
|
189
|
+
*/
|
|
190
|
+
noteListRev(rev: unknown): boolean;
|
|
191
|
+
private applyBody;
|
|
192
|
+
/**
|
|
193
|
+
* Where a definition lands (RFC §6.1): with `instance`, that instance's own;
|
|
194
|
+
* without, the toolset's (for a toolset without instances, its only one's).
|
|
195
|
+
*/
|
|
196
|
+
private defKeyFor;
|
|
197
|
+
/** Where a visibility statement lands. For a toolset with instances, `instance` is required; a statement without one is ignored. */
|
|
198
|
+
private keysFor;
|
|
199
|
+
private setVisible;
|
|
200
|
+
private dropKey;
|
|
201
|
+
/** The result of a toolsets/open: the instance is open whatever its hints say. */
|
|
202
|
+
noteOpened(toolset: string, instance: string | undefined, title: string | undefined): void;
|
|
203
|
+
/** toolsets/close succeeded: closed, whatever the hints said. */
|
|
204
|
+
noteClosed(toolset: string, instance: string | undefined): void;
|
|
205
|
+
/**
|
|
206
|
+
* toolsets/list (RFC §5.3): what the principal has open, with the full hint
|
|
207
|
+
* state of its dynamic tools, the truth for declared toolsets and dynamic
|
|
208
|
+
* tools outside them. Anything the host believed open and the server doesn't
|
|
209
|
+
* report is closed, never re-opened here: opening can start a new game.
|
|
210
|
+
* Returns what was lost, what the server says ended while no connection was
|
|
211
|
+
* told, its suggestions, and whether its rev skipped one.
|
|
212
|
+
*/
|
|
213
|
+
adopt(result: unknown): {
|
|
214
|
+
lost: OpenRecord[];
|
|
215
|
+
ended: Ended[];
|
|
216
|
+
suggest: Suggestion[];
|
|
217
|
+
skipped: boolean;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* What the agent should hear about an adoption: what ended while it was
|
|
221
|
+
* away, each `ended` id once however often the server repeats it (RFC
|
|
222
|
+
* §5.3), and what is closed now.
|
|
223
|
+
*/
|
|
224
|
+
adoptionNotes(lost: OpenRecord[], ended: Ended[]): string[];
|
|
225
|
+
openGroup(g: string): void;
|
|
226
|
+
closeGroup(g: string): void;
|
|
227
|
+
/** Apply pending static↔dynamic moves (RFC §4.2) at a boundary the host chooses. Returns what moved. */
|
|
228
|
+
applyMoves(): Array<{
|
|
229
|
+
name: string;
|
|
230
|
+
to: Presence;
|
|
231
|
+
}>;
|
|
232
|
+
/** The marker a key's announcements begin with, `[server/toolset:instance]`, which a reminder looks for. */
|
|
233
|
+
label(key: string): string;
|
|
234
|
+
callHint(key: string): string;
|
|
235
|
+
closeHint(key: string): string | null;
|
|
236
|
+
openHint(toolset: string, instance?: string): string;
|
|
237
|
+
/** The tool block for one key: its label, how to call, and the visible tools (new or changed ones described). */
|
|
238
|
+
toolBlock(key: string, tools: HintedTool[], opts?: {
|
|
239
|
+
describeAll?: boolean;
|
|
240
|
+
headed?: boolean;
|
|
241
|
+
title?: string;
|
|
242
|
+
}): string[];
|
|
243
|
+
/** What the model reads for a change set. `bare`: a key whose header the caller already printed. */
|
|
244
|
+
render(cs: ChangeSet, opts?: {
|
|
245
|
+
bare?: string;
|
|
246
|
+
}): string;
|
|
247
|
+
/** RFC §6.2: a suggestion is shown, never acted on. */
|
|
248
|
+
renderSuggestion(s: Suggestion): string;
|
|
249
|
+
/** The keys a reminder restates: every open key of this server's view. */
|
|
250
|
+
openKeys(): string[];
|
|
251
|
+
/** RFC §8.3 reminder: what is open, its current tools (described), how to call and close it. Null when nothing is open. */
|
|
252
|
+
reminder(): string | null;
|
|
253
|
+
/** look naming this server: what is open (with tools) and what can be opened. */
|
|
254
|
+
catalog(): string;
|
|
255
|
+
/** Where a tool can be called from now, for `look` naming it. */
|
|
256
|
+
toolStatus(tool: string): string;
|
|
257
|
+
}
|
|
258
|
+
export {};
|
|
259
|
+
//# sourceMappingURL=tool-presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-presence.d.ts","sourceRoot":"","sources":["../../../src/mcpl/tool-presence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAgD,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEpG,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AACD,MAAM,WAAW,UAAU;IAAG,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC5G,MAAM,WAAW,UAAU;IAAG,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAA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