aismemory 0.8.9 → 0.8.11
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 +61 -9
- package/dist/agent-key-mode.d.ts +26 -0
- package/dist/agent-key-mode.js +166 -40
- package/dist/agent-only-pass.d.ts +41 -0
- package/dist/agent-only-pass.js +539 -0
- package/dist/ais-http-error.js +6 -4
- package/dist/ais-http.d.ts +11 -0
- package/dist/ais-http.js +31 -17
- package/dist/cli/hooks.d.ts +40 -6
- package/dist/cli/hooks.js +318 -69
- package/dist/cli/install.d.ts +8 -0
- package/dist/cli/install.js +15 -0
- package/dist/cli/orientation-load.d.ts +18 -0
- package/dist/cli/orientation-load.js +50 -0
- package/dist/cli/read-claude-memory-tree.d.ts +37 -0
- package/dist/cli/read-claude-memory-tree.js +247 -2
- package/dist/cli/setup-core.js +7 -3
- package/dist/cli/slack.d.ts +2 -0
- package/dist/cli/slack.js +263 -0
- package/dist/cli/sync-memory.js +6 -3
- package/dist/cli-info.d.ts +1 -0
- package/dist/cli-info.js +4 -2
- package/dist/decision-card.d.ts +42 -0
- package/dist/decision-card.js +50 -0
- package/dist/decision-ledger.d.ts +24 -0
- package/dist/decision-ledger.js +59 -0
- package/dist/decision-receipt.d.ts +33 -0
- package/dist/decision-receipt.js +72 -0
- package/dist/device-poll.d.ts +16 -7
- package/dist/device-poll.js +31 -3
- package/dist/handoff-doc.d.ts +9 -0
- package/dist/handoff-doc.js +53 -0
- package/dist/hydration.d.ts +1 -1
- package/dist/hydration.js +7 -2
- package/dist/inbox-client.js +33 -26
- package/dist/index.js +281 -114
- package/dist/lesson-advice.d.ts +16 -0
- package/dist/lesson-advice.js +56 -0
- package/dist/lesson-tags.d.ts +6 -0
- package/dist/lesson-tags.js +7 -0
- package/dist/lessons.d.ts +2 -0
- package/dist/lessons.js +62 -0
- package/dist/library-tools.d.ts +22 -0
- package/dist/library-tools.js +72 -0
- package/dist/mcp/tools.d.ts +3 -0
- package/dist/mcp/tools.js +129 -49
- package/dist/mcp-instructions.d.ts +1 -1
- package/dist/mcp-instructions.js +4 -1
- package/dist/operating-layer-read.d.ts +38 -0
- package/dist/operating-layer-read.js +164 -0
- package/dist/pending-device-flow.js +1 -12
- package/dist/pipeline/bulk-store.d.ts +1 -0
- package/dist/pipeline/bulk-store.js +20 -0
- package/dist/pipeline/types.d.ts +2 -0
- package/dist/recall-warning.d.ts +14 -0
- package/dist/recall-warning.js +36 -0
- package/dist/request-timeout.d.ts +27 -2
- package/dist/request-timeout.js +92 -2
- package/dist/run-pass-mode.js +35 -29
- package/dist/session-identity.js +3 -1
- package/dist/session-start.d.ts +15 -5
- package/dist/session-start.js +57 -13
- package/dist/skill-fetch.d.ts +30 -0
- package/dist/skill-fetch.js +88 -0
- package/dist/slack-tools.d.ts +44 -0
- package/dist/slack-tools.js +156 -0
- package/dist/sources/local-claude.js +16 -2
- package/dist/sources/types.d.ts +2 -0
- package/dist/startup-identity.d.ts +4 -0
- package/dist/startup-identity.js +2 -0
- package/dist/tool-args.d.ts +28 -3
- package/dist/tool-args.js +92 -8
- package/dist/tool-scope-filter.d.ts +29 -0
- package/dist/tool-scope-filter.js +123 -0
- package/dist/version-check.d.ts +30 -3
- package/dist/version-check.js +59 -4
- package/dist/workspace-key-mode.js +37 -36
- package/package.json +4 -3
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filter the advertised MCP tool list by credential whoami scopes (CORBOT-78D43959).
|
|
3
|
+
*
|
|
4
|
+
* Rule: the server decides (whoami scopes); the client follows. API-key modes
|
|
5
|
+
* must not advertise tools the credential cannot call.
|
|
6
|
+
*
|
|
7
|
+
* whoami `scopes` are AIS REST subresource names (`memory`, `full-context`, …),
|
|
8
|
+
* not OAuth scope strings. Tools with no AIS route stay local or authMode-gated.
|
|
9
|
+
*/
|
|
10
|
+
/** Every MCP tool name registered in index.ts — keep in sync when adding tools. */
|
|
11
|
+
export const ALL_MCP_TOOL_NAMES = [
|
|
12
|
+
'remember',
|
|
13
|
+
'update_memory',
|
|
14
|
+
'recall',
|
|
15
|
+
'memory_get',
|
|
16
|
+
'skill_fetch',
|
|
17
|
+
'memory_forget',
|
|
18
|
+
'whoami',
|
|
19
|
+
'orientation_check',
|
|
20
|
+
'full_context',
|
|
21
|
+
'dream',
|
|
22
|
+
'handoff',
|
|
23
|
+
'agent_load',
|
|
24
|
+
'inbox_send',
|
|
25
|
+
'inbox_read',
|
|
26
|
+
'inbox_ack',
|
|
27
|
+
'slack_post',
|
|
28
|
+
'slack_read',
|
|
29
|
+
'goal_create',
|
|
30
|
+
'goal_list',
|
|
31
|
+
'goal_update_progress',
|
|
32
|
+
'goal_activate',
|
|
33
|
+
'goal_complete',
|
|
34
|
+
'operating_layer_put',
|
|
35
|
+
'skill_get',
|
|
36
|
+
'agent_archive',
|
|
37
|
+
'agent_delete',
|
|
38
|
+
'environment_manifest_get',
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Required whoami subresource for each tool, or a special marker:
|
|
42
|
+
* - string → must appear in credential scopes
|
|
43
|
+
* - 'local' → no AIS scope (always advertise)
|
|
44
|
+
* - 'owner' → never available under API-key modes
|
|
45
|
+
* - 'agent-load' → workspace-key only (matches call-time OutOfScope rules)
|
|
46
|
+
* - 'agent-key' → agent API key only, with no agent subresource scope
|
|
47
|
+
*/
|
|
48
|
+
const TOOL_SCOPE_RULE = {
|
|
49
|
+
remember: 'memory',
|
|
50
|
+
update_memory: 'memory',
|
|
51
|
+
recall: 'memory',
|
|
52
|
+
memory_get: 'memory',
|
|
53
|
+
// The fleet-skills endpoint authenticates the key and gates catalog visibility.
|
|
54
|
+
skill_fetch: 'agent-key',
|
|
55
|
+
memory_forget: 'memory',
|
|
56
|
+
whoami: 'whoami',
|
|
57
|
+
orientation_check: 'local',
|
|
58
|
+
full_context: 'full-context',
|
|
59
|
+
dream: 'dream',
|
|
60
|
+
handoff: 'handoff',
|
|
61
|
+
agent_load: 'agent-load',
|
|
62
|
+
inbox_send: 'inbox',
|
|
63
|
+
inbox_read: 'inbox',
|
|
64
|
+
inbox_ack: 'inbox',
|
|
65
|
+
slack_post: 'whoami',
|
|
66
|
+
slack_read: 'inbox',
|
|
67
|
+
goal_create: 'goals',
|
|
68
|
+
goal_list: 'goals',
|
|
69
|
+
goal_update_progress: 'goals',
|
|
70
|
+
goal_activate: 'goals',
|
|
71
|
+
goal_complete: 'goals',
|
|
72
|
+
operating_layer_put: 'operating-layer',
|
|
73
|
+
skill_get: 'operating-layer',
|
|
74
|
+
agent_archive: 'owner',
|
|
75
|
+
agent_delete: 'owner',
|
|
76
|
+
environment_manifest_get: 'environment-manifest',
|
|
77
|
+
};
|
|
78
|
+
function isKnownToolName(name) {
|
|
79
|
+
return ALL_MCP_TOOL_NAMES.includes(name);
|
|
80
|
+
}
|
|
81
|
+
function isToolAllowed(name, scopes, authMode) {
|
|
82
|
+
if (!isKnownToolName(name)) {
|
|
83
|
+
// Deny unknown tools under an allowlist — do not advertise what we cannot verify.
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
// Among the scoped key modes, only agent-key mode implements these tools.
|
|
87
|
+
if ((name === 'slack_post' || name === 'slack_read' || name === 'skill_get') && authMode !== 'agent-api-key')
|
|
88
|
+
return false;
|
|
89
|
+
const rule = TOOL_SCOPE_RULE[name];
|
|
90
|
+
if (rule === 'local')
|
|
91
|
+
return true;
|
|
92
|
+
if (rule === 'owner')
|
|
93
|
+
return false;
|
|
94
|
+
if (rule === 'agent-load')
|
|
95
|
+
return authMode === 'workspace-key';
|
|
96
|
+
if (rule === 'agent-key')
|
|
97
|
+
return authMode === 'agent-api-key';
|
|
98
|
+
return scopes.has(rule);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Return the subset of `allTools` the credential may call.
|
|
102
|
+
*
|
|
103
|
+
* When whoami did not self-describe, or scopeModel is not an allowlist, return
|
|
104
|
+
* the full list (safe fallback for older AIS / unrestricted owner sessions).
|
|
105
|
+
* Report hidden names once when an allowlist removes tools.
|
|
106
|
+
*/
|
|
107
|
+
export function filterToolsByCredentialScopes(allTools, credential, reportHiddenTools) {
|
|
108
|
+
if (!credential.selfDescribed || credential.scopeModel !== 'allowlist') {
|
|
109
|
+
return [...allTools];
|
|
110
|
+
}
|
|
111
|
+
const scopes = new Set(credential.scopes ?? []);
|
|
112
|
+
const hiddenNames = [];
|
|
113
|
+
const advertisedTools = allTools.filter((tool) => {
|
|
114
|
+
if (isToolAllowed(tool.name, scopes, credential.authMode))
|
|
115
|
+
return true;
|
|
116
|
+
hiddenNames.push(tool.name);
|
|
117
|
+
return false;
|
|
118
|
+
});
|
|
119
|
+
if (hiddenNames.length > 0)
|
|
120
|
+
reportHiddenTools?.(hiddenNames);
|
|
121
|
+
return advertisedTools;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=tool-scope-filter.js.map
|
package/dist/version-check.d.ts
CHANGED
|
@@ -55,6 +55,12 @@ export declare function classifyVersion(current: string, latest: string): Versio
|
|
|
55
55
|
* package: a global install, and an npx line in a client configuration.
|
|
56
56
|
*/
|
|
57
57
|
export declare function formatUpdateNotice(current: string, latest: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Plain-words notice when the installed package is below the server's
|
|
60
|
+
* supported minimum (CORBOT-4142F77E). Stronger than a soft "update
|
|
61
|
+
* available": features can go missing until the package is upgraded.
|
|
62
|
+
*/
|
|
63
|
+
export declare function formatMinimumNotice(current: string, minimum: string): string;
|
|
58
64
|
/**
|
|
59
65
|
* Resolve the update status. Resolves — never rejects: an unreachable registry,
|
|
60
66
|
* a malformed response, or a disabled check all come back as a skip.
|
|
@@ -66,14 +72,35 @@ export declare function checkForUpdate(options: VersionCheckOptions): Promise<Ve
|
|
|
66
72
|
* settled answer later through `getUpdateNotice()`.
|
|
67
73
|
*/
|
|
68
74
|
export declare function startVersionCheck(options: VersionCheckOptions): Promise<VersionCheckResult>;
|
|
69
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Notice when the installed package is below the server's supported minimum.
|
|
77
|
+
* Prefers a structured `X-AIS-Min-Client-Version` (formatted here with the
|
|
78
|
+
* exact update commands) and falls back to a free-text `X-AIS-Update-Notice`
|
|
79
|
+
* from older servers. `currentVersion` is for tests; production reads the
|
|
80
|
+
* package manifest.
|
|
81
|
+
*/
|
|
82
|
+
export declare function getBelowMinimumNotice(currentVersion?: string): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* Soft registry "update available" notice only — not the below-minimum path.
|
|
85
|
+
* Used by tool handlers that still limit soft notices to whoami / full_context.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getSoftUpdateNotice(): string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Settled notice for doctors and callers that want either signal. Below-minimum
|
|
90
|
+
* wins over a soft registry update (CORBOT-4142F77E).
|
|
91
|
+
*/
|
|
70
92
|
export declare function getUpdateNotice(): string | null;
|
|
71
93
|
/**
|
|
72
94
|
* Remember the `X-AIS-Update-Notice` text the server sent on a response
|
|
73
|
-
* (CORBOT-374498FD).
|
|
74
|
-
*
|
|
95
|
+
* (CORBOT-374498FD). Used when the server has not also sent a structured
|
|
96
|
+
* minimum header; `getBelowMinimumNotice()` returns it as-is.
|
|
75
97
|
*/
|
|
76
98
|
export declare function setServerUpdateNotice(notice: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Remember the structured minimum from `X-AIS-Min-Client-Version`
|
|
101
|
+
* (CORBOT-4142F77E). The client compares and formats the plain notice.
|
|
102
|
+
*/
|
|
103
|
+
export declare function setServerMinimumVersion(minimum: string): void;
|
|
77
104
|
/** The latest published version the check learned, or null when it has not run or was skipped. */
|
|
78
105
|
export declare function getLatestKnownVersion(): string | null;
|
|
79
106
|
/** Drops the process-wide notice. Used by tests to isolate cases. */
|
package/dist/version-check.js
CHANGED
|
@@ -123,6 +123,16 @@ export function formatUpdateNotice(current, latest) {
|
|
|
123
123
|
'To update an npx setup, set the command in your model context protocol client configuration to "npx -y aismemory@latest" and restart the client. ' +
|
|
124
124
|
'Set AISMEMORY_VERSION_CHECK=off to stop this check.');
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Plain-words notice when the installed package is below the server's
|
|
128
|
+
* supported minimum (CORBOT-4142F77E). Stronger than a soft "update
|
|
129
|
+
* available": features can go missing until the package is upgraded.
|
|
130
|
+
*/
|
|
131
|
+
export function formatMinimumNotice(current, minimum) {
|
|
132
|
+
return (`aismemory ${current} is below the supported minimum ${minimum}. ` +
|
|
133
|
+
'Update before continuing. To update a global install, run: npm install -g aismemory@latest. ' +
|
|
134
|
+
'To update an npx setup, set the command in your model context protocol client configuration to "npx -y aismemory@latest" and restart the client.');
|
|
135
|
+
}
|
|
126
136
|
function readCache(home, now, ttlMs) {
|
|
127
137
|
try {
|
|
128
138
|
const parsed = JSON.parse(readFileSync(versionCacheFilePath(home), 'utf-8'));
|
|
@@ -208,6 +218,8 @@ export async function checkForUpdate(options) {
|
|
|
208
218
|
let updateNotice = null;
|
|
209
219
|
let latestKnownVersion = null;
|
|
210
220
|
let serverUpdateNotice = null;
|
|
221
|
+
/** Structured minimum from `X-AIS-Min-Client-Version` (CORBOT-4142F77E). */
|
|
222
|
+
let serverMinimumVersion = null;
|
|
211
223
|
/**
|
|
212
224
|
* Start the check without blocking the caller. The returned promise is for
|
|
213
225
|
* tests; production callers use `void startVersionCheck(...)` and read the
|
|
@@ -230,20 +242,62 @@ export async function startVersionCheck(options) {
|
|
|
230
242
|
}
|
|
231
243
|
return result;
|
|
232
244
|
}
|
|
233
|
-
/**
|
|
245
|
+
/**
|
|
246
|
+
* Notice when the installed package is below the server's supported minimum.
|
|
247
|
+
* Prefers a structured `X-AIS-Min-Client-Version` (formatted here with the
|
|
248
|
+
* exact update commands) and falls back to a free-text `X-AIS-Update-Notice`
|
|
249
|
+
* from older servers. `currentVersion` is for tests; production reads the
|
|
250
|
+
* package manifest.
|
|
251
|
+
*/
|
|
252
|
+
export function getBelowMinimumNotice(currentVersion) {
|
|
253
|
+
if (serverMinimumVersion !== null) {
|
|
254
|
+
let current;
|
|
255
|
+
try {
|
|
256
|
+
current = currentVersion ?? readPackageVersion();
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
return serverUpdateNotice;
|
|
260
|
+
}
|
|
261
|
+
if (compareVersions(current, serverMinimumVersion) < 0) {
|
|
262
|
+
return formatMinimumNotice(current, serverMinimumVersion);
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
return serverUpdateNotice;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Soft registry "update available" notice only — not the below-minimum path.
|
|
270
|
+
* Used by tool handlers that still limit soft notices to whoami / full_context.
|
|
271
|
+
*/
|
|
272
|
+
export function getSoftUpdateNotice() {
|
|
273
|
+
return updateNotice;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Settled notice for doctors and callers that want either signal. Below-minimum
|
|
277
|
+
* wins over a soft registry update (CORBOT-4142F77E).
|
|
278
|
+
*/
|
|
234
279
|
export function getUpdateNotice() {
|
|
235
|
-
return
|
|
280
|
+
return getBelowMinimumNotice() ?? updateNotice;
|
|
236
281
|
}
|
|
237
282
|
/**
|
|
238
283
|
* Remember the `X-AIS-Update-Notice` text the server sent on a response
|
|
239
|
-
* (CORBOT-374498FD).
|
|
240
|
-
*
|
|
284
|
+
* (CORBOT-374498FD). Used when the server has not also sent a structured
|
|
285
|
+
* minimum header; `getBelowMinimumNotice()` returns it as-is.
|
|
241
286
|
*/
|
|
242
287
|
export function setServerUpdateNotice(notice) {
|
|
243
288
|
const trimmed = notice.trim();
|
|
244
289
|
if (trimmed !== '')
|
|
245
290
|
serverUpdateNotice = trimmed;
|
|
246
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Remember the structured minimum from `X-AIS-Min-Client-Version`
|
|
294
|
+
* (CORBOT-4142F77E). The client compares and formats the plain notice.
|
|
295
|
+
*/
|
|
296
|
+
export function setServerMinimumVersion(minimum) {
|
|
297
|
+
const trimmed = minimum.trim().replace(/^v/i, '');
|
|
298
|
+
if (trimmed !== '')
|
|
299
|
+
serverMinimumVersion = trimmed;
|
|
300
|
+
}
|
|
247
301
|
/** The latest published version the check learned, or null when it has not run or was skipped. */
|
|
248
302
|
export function getLatestKnownVersion() {
|
|
249
303
|
return latestKnownVersion;
|
|
@@ -253,5 +307,6 @@ export function clearUpdateNotice() {
|
|
|
253
307
|
updateNotice = null;
|
|
254
308
|
latestKnownVersion = null;
|
|
255
309
|
serverUpdateNotice = null;
|
|
310
|
+
serverMinimumVersion = null;
|
|
256
311
|
}
|
|
257
312
|
//# sourceMappingURL=version-check.js.map
|
|
@@ -17,20 +17,22 @@
|
|
|
17
17
|
* Precedence: workspace key -> agent API key -> DID/device flow.
|
|
18
18
|
*/
|
|
19
19
|
import { SESSION_START_WORKSPACE_KEY_NOTE } from './session-start.js';
|
|
20
|
+
import { handoffDocFields, withHandoffDocWarning } from './handoff-doc.js';
|
|
20
21
|
import { AisHttpError, duplicateMemoryResult } from './ais-http-error.js';
|
|
21
|
-
import { AIS_GET_RETRYABLE_STATUSES, AIS_GET_RETRY_DELAY_MS } from './ais-http.js';
|
|
22
|
+
import { AIS_GET_RETRYABLE_STATUSES, AIS_GET_RETRY_DELAY_MS, captureServerVersionHeaders, withAisClientVersion, } from './ais-http.js';
|
|
22
23
|
import { captureCredentialExpiry, withCredentialExpiry } from './credential-expiry.js';
|
|
23
|
-
import { getAisRequestTimeoutMs, toAisRequestError } from './request-timeout.js';
|
|
24
|
+
import { aisRequestSignal, getAisRequestTimeoutMs, setInboxReadStage, toAisRequestError } from './request-timeout.js';
|
|
24
25
|
import { withDeclaredAgent } from './declared-agent.js';
|
|
25
26
|
import { emitTelemetry } from './telemetry.js';
|
|
26
27
|
import { OutOfScopeToolError } from './agent-key-mode.js';
|
|
28
|
+
import { SKILL_GET_TOOL, SKILL_GET_KEY_MODE_DETAIL } from './operating-layer-read.js';
|
|
27
29
|
import { OPERATING_LAYER_PUT_TOOL, OPERATING_LAYER_PUT_KEY_MODE_DETAIL } from './operating-layer-write.js';
|
|
28
30
|
import { retryAfterOf, shouldHonourRetryAfter, sleepSeconds } from './retry-after.js';
|
|
29
31
|
import { readInboxAndMaybeAck } from './inbox-client.js';
|
|
30
|
-
import {
|
|
32
|
+
import { orientAgainstStoredManifest } from './cli/orientation-load.js';
|
|
31
33
|
import { AGENT_ARCHIVE_KEY_MODE_DETAIL } from './agent-archive.js';
|
|
32
34
|
import { fetchCredentialWhoami } from './credential-whoami.js';
|
|
33
|
-
import { parseEmptyToolArgs, parseRecallArgs, parseMemoryGetArgs, buildMemoryGetPath, shapeMemoryGetResult, buildFullContextQuery, parseFullContextArgs, buildRememberStoreBody, shapeRememberResult, parseRememberArgs, parseAgentLoadArgs, parseGoalCreateArgs, parseGoalListArgs, parseGoalUpdateProgressArgs, parseGoalActivateArgs, parseGoalCompleteArgs, parseInboxSendArgs, parseInboxReadArgs, parseInboxAckArgs, parseHandoffArgs, } from './tool-args.js';
|
|
35
|
+
import { parseEmptyToolArgs, parseRecallArgs, buildRecallPath, shapeRecallResult, parseMemoryGetArgs, buildMemoryGetPath, shapeMemoryGetResult, buildFullContextQuery, parseFullContextArgs, buildRememberStoreBody, shapeRememberResult, parseRememberArgs, parseUpdateMemoryArgs, parseAgentLoadArgs, parseGoalCreateArgs, parseGoalListArgs, parseGoalUpdateProgressArgs, parseGoalActivateArgs, parseGoalCompleteArgs, parseInboxSendArgs, parseInboxReadArgs, parseInboxAckArgs, parseHandoffArgs, } from './tool-args.js';
|
|
34
36
|
import { resolveDreamResponse } from './dream-poll.js';
|
|
35
37
|
import { forgetOwnMemory } from './memory-forget.js';
|
|
36
38
|
/** Thrown by loadWorkspaceKeyConfig when AIS_WORKSPACE_KEY is set without AIS_AGENT_ID. */
|
|
@@ -94,16 +96,18 @@ export function loadWorkspaceKeyConfig(env = process.env) {
|
|
|
94
96
|
}
|
|
95
97
|
return { workspaceKey, agentId };
|
|
96
98
|
}
|
|
97
|
-
async function readJson(res) {
|
|
99
|
+
async function readJson(res, path, method = 'GET') {
|
|
98
100
|
const warning = captureCredentialExpiry(res);
|
|
101
|
+
setInboxReadStage(`${method} ${path}: body`);
|
|
99
102
|
const data = await res.json().catch(() => null);
|
|
103
|
+
setInboxReadStage(`${method} ${path}: body`);
|
|
100
104
|
return withCredentialExpiry(data, warning);
|
|
101
105
|
}
|
|
102
106
|
export async function wksKeyPost(aisUrl, path, workspaceKey, body, fetchImpl = globalThis.fetch) {
|
|
103
|
-
const headers = withDeclaredAgent({
|
|
107
|
+
const headers = withDeclaredAgent(withAisClientVersion({
|
|
104
108
|
'Content-Type': 'application/json',
|
|
105
109
|
'x-workspace-key': workspaceKey,
|
|
106
|
-
});
|
|
110
|
+
}));
|
|
107
111
|
const timeoutMs = getAisRequestTimeoutMs();
|
|
108
112
|
let res;
|
|
109
113
|
try {
|
|
@@ -111,7 +115,7 @@ export async function wksKeyPost(aisUrl, path, workspaceKey, body, fetchImpl = g
|
|
|
111
115
|
method: 'POST',
|
|
112
116
|
headers,
|
|
113
117
|
body: JSON.stringify(body),
|
|
114
|
-
signal:
|
|
118
|
+
signal: aisRequestSignal(path, timeoutMs, 'POST'),
|
|
115
119
|
});
|
|
116
120
|
}
|
|
117
121
|
catch (err) {
|
|
@@ -119,7 +123,8 @@ export async function wksKeyPost(aisUrl, path, workspaceKey, body, fetchImpl = g
|
|
|
119
123
|
emitTelemetry({ event: 'ais.http.failure', path, error: wrapped instanceof Error ? wrapped.message : String(wrapped) });
|
|
120
124
|
throw wrapped;
|
|
121
125
|
}
|
|
122
|
-
|
|
126
|
+
captureServerVersionHeaders(res);
|
|
127
|
+
const data = await readJson(res, path, 'POST');
|
|
123
128
|
if (!res.ok) {
|
|
124
129
|
emitTelemetry({ event: 'ais.http.failure', path, httpStatus: res.status, error: `HTTP ${res.status}` });
|
|
125
130
|
throw new AisHttpError(res.status, path, data, retryAfterOf(res));
|
|
@@ -133,8 +138,8 @@ export async function wksKeyGet(aisUrl, path, workspaceKey, fetchImpl = globalTh
|
|
|
133
138
|
for (;;) {
|
|
134
139
|
try {
|
|
135
140
|
res = await fetchImpl(`${aisUrl}${path}`, {
|
|
136
|
-
headers: withDeclaredAgent({ 'x-workspace-key': workspaceKey }),
|
|
137
|
-
signal:
|
|
141
|
+
headers: withDeclaredAgent(withAisClientVersion({ 'x-workspace-key': workspaceKey })),
|
|
142
|
+
signal: aisRequestSignal(path, timeoutMs),
|
|
138
143
|
});
|
|
139
144
|
}
|
|
140
145
|
catch (err) {
|
|
@@ -150,6 +155,7 @@ export async function wksKeyGet(aisUrl, path, workspaceKey, fetchImpl = globalTh
|
|
|
150
155
|
captureCredentialExpiry(res);
|
|
151
156
|
attempt += 1;
|
|
152
157
|
emitTelemetry({ event: 'ais.http.retry', path, httpStatus: res.status });
|
|
158
|
+
setInboxReadStage(`GET ${path}: retry delay`);
|
|
153
159
|
if (retryAfter === null) {
|
|
154
160
|
await new Promise((resolve) => setTimeout(resolve, AIS_GET_RETRY_DELAY_MS));
|
|
155
161
|
}
|
|
@@ -160,7 +166,8 @@ export async function wksKeyGet(aisUrl, path, workspaceKey, fetchImpl = globalTh
|
|
|
160
166
|
}
|
|
161
167
|
break;
|
|
162
168
|
}
|
|
163
|
-
|
|
169
|
+
captureServerVersionHeaders(res);
|
|
170
|
+
const data = await readJson(res, path);
|
|
164
171
|
if (!res.ok) {
|
|
165
172
|
emitTelemetry({ event: 'ais.http.failure', path, httpStatus: res.status, error: `HTTP ${res.status}` });
|
|
166
173
|
throw new AisHttpError(res.status, path, data, retryAfterOf(res));
|
|
@@ -168,10 +175,10 @@ export async function wksKeyGet(aisUrl, path, workspaceKey, fetchImpl = globalTh
|
|
|
168
175
|
return data;
|
|
169
176
|
}
|
|
170
177
|
export async function wksKeyPatch(aisUrl, path, workspaceKey, body, fetchImpl = globalThis.fetch) {
|
|
171
|
-
const headers = withDeclaredAgent({
|
|
178
|
+
const headers = withDeclaredAgent(withAisClientVersion({
|
|
172
179
|
'Content-Type': 'application/json',
|
|
173
180
|
'x-workspace-key': workspaceKey,
|
|
174
|
-
});
|
|
181
|
+
}));
|
|
175
182
|
const timeoutMs = getAisRequestTimeoutMs();
|
|
176
183
|
let res;
|
|
177
184
|
try {
|
|
@@ -179,7 +186,7 @@ export async function wksKeyPatch(aisUrl, path, workspaceKey, body, fetchImpl =
|
|
|
179
186
|
method: 'PATCH',
|
|
180
187
|
headers,
|
|
181
188
|
body: JSON.stringify(body),
|
|
182
|
-
signal:
|
|
189
|
+
signal: aisRequestSignal(path, timeoutMs, 'PATCH'),
|
|
183
190
|
});
|
|
184
191
|
}
|
|
185
192
|
catch (err) {
|
|
@@ -187,7 +194,8 @@ export async function wksKeyPatch(aisUrl, path, workspaceKey, body, fetchImpl =
|
|
|
187
194
|
emitTelemetry({ event: 'ais.http.failure', path, error: wrapped instanceof Error ? wrapped.message : String(wrapped) });
|
|
188
195
|
throw wrapped;
|
|
189
196
|
}
|
|
190
|
-
|
|
197
|
+
captureServerVersionHeaders(res);
|
|
198
|
+
const data = await readJson(res, path, 'PATCH');
|
|
191
199
|
if (!res.ok) {
|
|
192
200
|
emitTelemetry({ event: 'ais.http.failure', path, httpStatus: res.status, error: `HTTP ${res.status}` });
|
|
193
201
|
throw new AisHttpError(res.status, path, data, retryAfterOf(res));
|
|
@@ -213,22 +221,13 @@ export async function dispatchToolWorkspaceKeyMode(aisUrl, config, name, rawArgs
|
|
|
213
221
|
throw err;
|
|
214
222
|
}
|
|
215
223
|
}
|
|
224
|
+
case 'update_memory': {
|
|
225
|
+
const { memoryId, ...update } = parseUpdateMemoryArgs(rawArgs);
|
|
226
|
+
return wksKeyPatch(aisUrl, `/v1/agents/${agentId}/memory/${memoryId}`, workspaceKey, update, fetchImpl);
|
|
227
|
+
}
|
|
216
228
|
case 'recall': {
|
|
217
229
|
const args = parseRecallArgs(rawArgs);
|
|
218
|
-
|
|
219
|
-
params.set('query', args.query);
|
|
220
|
-
if (args.limit !== undefined)
|
|
221
|
-
params.set('limit', String(args.limit));
|
|
222
|
-
if (args.type !== undefined)
|
|
223
|
-
params.set('types', args.type);
|
|
224
|
-
if (args.tags !== undefined && args.tags.length > 0)
|
|
225
|
-
params.set('tags', args.tags.join(','));
|
|
226
|
-
if (args.orderBy !== undefined)
|
|
227
|
-
params.set('orderBy', args.orderBy);
|
|
228
|
-
if (args.principalAgentId !== undefined) {
|
|
229
|
-
params.set('principalAgentId', args.principalAgentId);
|
|
230
|
-
}
|
|
231
|
-
return wksKeyGet(aisUrl, `/v1/agents/${agentId}/memory?${params}`, workspaceKey, fetchImpl);
|
|
230
|
+
return shapeRecallResult(await wksKeyGet(aisUrl, buildRecallPath(agentId, args), workspaceKey, fetchImpl), args);
|
|
232
231
|
}
|
|
233
232
|
case 'memory_get': {
|
|
234
233
|
const getArgs = parseMemoryGetArgs(rawArgs);
|
|
@@ -240,7 +239,7 @@ export async function dispatchToolWorkspaceKeyMode(aisUrl, config, name, rawArgs
|
|
|
240
239
|
const fcArgs = parseFullContextArgs(rawArgs);
|
|
241
240
|
const fcQs = buildFullContextQuery(fcArgs);
|
|
242
241
|
const fcPath = `/v1/agents/${agentId}/full-context${fcQs}`;
|
|
243
|
-
return wksKeyGet(aisUrl, fcPath, workspaceKey, fetchImpl);
|
|
242
|
+
return withHandoffDocWarning(await wksKeyGet(aisUrl, fcPath, workspaceKey, fetchImpl));
|
|
244
243
|
}
|
|
245
244
|
case 'dream':
|
|
246
245
|
parseEmptyToolArgs(rawArgs);
|
|
@@ -251,11 +250,11 @@ export async function dispatchToolWorkspaceKeyMode(aisUrl, config, name, rawArgs
|
|
|
251
250
|
// key can do, fall back to the liveness probe on an older server.
|
|
252
251
|
return fetchCredentialWhoami(agentId, 'workspace-key', () => wksKeyGet(aisUrl, `/v1/agents/${agentId}/whoami`, workspaceKey, fetchImpl), () => wksKeyGet(aisUrl, `/v1/agents/${agentId}/memory?limit=1`, workspaceKey, fetchImpl));
|
|
253
252
|
}
|
|
253
|
+
case 'environment_manifest_get':
|
|
254
|
+
parseEmptyToolArgs(rawArgs);
|
|
255
|
+
return wksKeyGet(aisUrl, `/v1/agents/${agentId}/environment-manifest`, workspaceKey, fetchImpl);
|
|
254
256
|
case 'orientation_check':
|
|
255
|
-
|
|
256
|
-
// needed. orient() validates its own input and throws on a malformed
|
|
257
|
-
// manifest; the caller's outer catch turns that into an {error} result.
|
|
258
|
-
return orient(rawArgs);
|
|
257
|
+
return orientAgainstStoredManifest(rawArgs, agentId, () => wksKeyGet(aisUrl, `/v1/agents/${agentId}/environment-manifest`, workspaceKey, fetchImpl));
|
|
259
258
|
case 'agent_load': {
|
|
260
259
|
const args = parseAgentLoadArgs(rawArgs);
|
|
261
260
|
const targetAgentId = args.query.trim();
|
|
@@ -355,12 +354,14 @@ export async function dispatchToolWorkspaceKeyMode(aisUrl, config, name, rawArgs
|
|
|
355
354
|
return wksKeyPost(aisUrl, `/v1/agents/${agentId}/handoff`, workspaceKey, {
|
|
356
355
|
...(args.summary !== undefined ? { summary: args.summary } : {}),
|
|
357
356
|
...(args.keyLearnings !== undefined ? { keyLearnings: args.keyLearnings } : {}),
|
|
358
|
-
...(args.docPath
|
|
357
|
+
...await handoffDocFields(args.docPath),
|
|
359
358
|
...(args.docPrUrl !== undefined ? { docPrUrl: args.docPrUrl } : {}),
|
|
360
359
|
}, fetchImpl);
|
|
361
360
|
}
|
|
362
361
|
case OPERATING_LAYER_PUT_TOOL:
|
|
363
362
|
throw new OutOfScopeToolError(name, OPERATING_LAYER_PUT_KEY_MODE_DETAIL);
|
|
363
|
+
case SKILL_GET_TOOL:
|
|
364
|
+
throw new OutOfScopeToolError(name, SKILL_GET_KEY_MODE_DETAIL);
|
|
364
365
|
case 'agent_archive':
|
|
365
366
|
case 'agent_delete':
|
|
366
367
|
throw new OutOfScopeToolError(name, AGENT_ARCHIVE_KEY_MODE_DETAIL);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aismemory",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.11",
|
|
4
4
|
"description": "Persistent memory for AI agents. MCP server that connects to Agent Identity Service.",
|
|
5
5
|
"mcpName": "ai.agentsandswarms/ais-memory",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"aismemory": "dist/index.js",
|
|
9
9
|
"aismemory-sync": "dist/cli/sync-memory.js",
|
|
10
10
|
"aismemory-doctor": "dist/cli/doctor.js",
|
|
11
|
-
"aismemory-pull": "dist/cli/pull-memory.js"
|
|
11
|
+
"aismemory-pull": "dist/cli/pull-memory.js",
|
|
12
|
+
"aismemory-slack": "dist/cli/slack.js"
|
|
12
13
|
},
|
|
13
14
|
"main": "dist/index.js",
|
|
14
15
|
"files": [
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
"README.md"
|
|
19
20
|
],
|
|
20
21
|
"scripts": {
|
|
21
|
-
"build": "tsc && chmod +x dist/index.js dist/cli/sync-memory.js dist/cli/doctor.js dist/cli/pull-memory.js",
|
|
22
|
+
"build": "tsc && chmod +x dist/index.js dist/cli/sync-memory.js dist/cli/doctor.js dist/cli/pull-memory.js dist/cli/slack.js",
|
|
22
23
|
"prepack": "npm run build",
|
|
23
24
|
"sync": "node dist/cli/sync-memory.js",
|
|
24
25
|
"test": "vitest run",
|