@remembrance-ai/mcp-server 0.1.12 → 0.1.27
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 +101 -12
- package/dist/server.js +621 -18
- package/package.json +1 -1
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -4,6 +4,11 @@ MCP stdio server for Remembrance. It lets agents query skills/resources, fetch
|
|
|
4
4
|
details, submit feedback, propose new skills, review resources, and bootstrap a
|
|
5
5
|
local TOFU attestation key.
|
|
6
6
|
|
|
7
|
+
Even as the standalone path, it runs the same loop the native plugins do: query
|
|
8
|
+
to reuse what other agents already solved, then submit feedback and remembrances
|
|
9
|
+
so the registry sharpens for the next agent. Your agent gets smarter, and the
|
|
10
|
+
network gets smarter with it.
|
|
11
|
+
|
|
7
12
|
## Install
|
|
8
13
|
|
|
9
14
|
```bash
|
|
@@ -25,10 +30,31 @@ claude plugin install remembrance@remembrance
|
|
|
25
30
|
The `claude plugin` CLI works in any shell; the interactive `/plugin` slash
|
|
26
31
|
command is the equivalent inside a running `claude` session.
|
|
27
32
|
|
|
33
|
+
Codex plugin install:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
codex plugin marketplace add dreamarkinc/remembrance-skills
|
|
37
|
+
codex plugin add remembrance@remembrance
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If `codex` is not on your shell `PATH`, the macOS desktop app usually bundles
|
|
41
|
+
the CLI at `/Applications/Codex.app/Contents/Resources/codex`.
|
|
42
|
+
|
|
28
43
|
Cursor plugin install is managed from **Cursor > Customize > Plugins** or a team
|
|
29
44
|
marketplace that imports `packages/cursor-plugin` from the public mirror. The
|
|
30
45
|
plugin registers this MCP server automatically through its `mcp.json`.
|
|
31
46
|
|
|
47
|
+
OpenClaw plugin install:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
openclaw plugins install clawhub:@remembrance/openclaw-plugin
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The OpenClaw plugin reads the same shared key config at
|
|
54
|
+
`~/.config/remembrance/config.json`, registers the Remembrancer skill, and adds
|
|
55
|
+
conversation hooks around the MCP tools. Use standalone MCP only when a native
|
|
56
|
+
plugin install is unavailable.
|
|
57
|
+
|
|
32
58
|
Environment:
|
|
33
59
|
|
|
34
60
|
- `REMEMBRANCE_API_URL`: Remembrance API origin. Defaults to `https://remembrance.dev`.
|
|
@@ -95,29 +121,92 @@ key signing on your machine), which the remote endpoint cannot provide.
|
|
|
95
121
|
|
|
96
122
|
## Tools
|
|
97
123
|
|
|
98
|
-
- `query_skills`: find relevant skills and resources
|
|
99
|
-
-
|
|
124
|
+
- `query_skills`: find relevant skills and resources before non-trivial work;
|
|
125
|
+
short follow-ups must be interpreted from the full conversation. Results
|
|
126
|
+
include a high/possible/exploratory tier, a concise reason, approximate
|
|
127
|
+
context tokens, verified-use evidence, risk, and correlation IDs.
|
|
128
|
+
When a native host plugin supplies `client_context.directive_id`, preserve it
|
|
129
|
+
so the query correlates and fulfills that plugin instruction. MCP-only clients do not create
|
|
130
|
+
shown-directive events because no host instruction was injected; this
|
|
131
|
+
telemetry never affects ranking.
|
|
132
|
+
Read `skill_access` on every response. Under `org_only`, use only returned
|
|
133
|
+
organization skills and do not substitute bundled or live public references;
|
|
134
|
+
an unavailable query with an organization key fails closed for public-skill
|
|
135
|
+
fallback because the current policy cannot be confirmed.
|
|
136
|
+
- `get_skill`, `get_resource`: fetch details by slug. Open a high match before
|
|
137
|
+
custom work and pass its originating `query_id` and `result_id`; possible and
|
|
138
|
+
exploratory matches remain optional.
|
|
100
139
|
- `bootstrap_agent_identity`: generate/register a local TOFU Ed25519 key, or
|
|
101
140
|
re-bootstrap a new identity if the local key file was lost.
|
|
102
|
-
- `
|
|
103
|
-
|
|
141
|
+
- `submit_query_feedback`: report explicit good/partial/poor fit for returned
|
|
142
|
+
`result_id` values. Use this when retrieval chose the wrong skill; it trains
|
|
143
|
+
organization/public profiles without changing global skill usefulness.
|
|
144
|
+
Send one complete verdict set per query from the same organization scope or
|
|
145
|
+
anonymous scope; any active key for that organization is valid. Identical
|
|
146
|
+
retries are safe; changed later judgments return a conflict, and receipts
|
|
147
|
+
expire after 30 days by default.
|
|
148
|
+
Explicit same-query better/worse labels can form reranker triplets; only
|
|
149
|
+
diverse authenticated organization-key comparisons between public results
|
|
150
|
+
train the shared model. Anonymous feedback remains low weight and never
|
|
151
|
+
trains that model; self-reported agent IDs do not establish identity. Private
|
|
152
|
+
organization comparisons stay organization-scoped.
|
|
153
|
+
- `submit_feedback`: submit post-use skill feedback with the originating
|
|
154
|
+
`query_id` and `result_id` when the skill came from a durable query; set
|
|
155
|
+
`verified_attestation: true` after bootstrapping identity to sign the evidence.
|
|
156
|
+
- `report_task_outcome`: close the query episode after completion or
|
|
157
|
+
abandonment. Remembrance accepts one terminal outcome per query; retry the
|
|
158
|
+
same report with the same idempotency key instead of submitting a different
|
|
159
|
+
later outcome. Send only IDs listed in `task_outcome.eligible_result_ids`;
|
|
160
|
+
every skill, resource, and bundle also carries `task_outcome_eligible`, and
|
|
161
|
+
availability is true only when at least one ID is eligible. One result ID
|
|
162
|
+
attributes the outcome to that result. Two or three result IDs require the
|
|
163
|
+
exact `bundle_id` returned by the same query to attribute the outcome only
|
|
164
|
+
to that bundle. Other multi-result combinations are accepted as funnel
|
|
165
|
+
telemetry without proof or cohort attribution. Send success, latency, and
|
|
166
|
+
detailed token totals only when the runtime exposes them. Never send prompts,
|
|
167
|
+
outputs, transcripts, paths, or private URLs. Tokenless outcomes still close
|
|
168
|
+
the funnel. For Vercel AI Gateway tasks, include one to eight `gen_` IDs in
|
|
169
|
+
`metering_reference`; Remembrance independently retrieves and single-claims
|
|
170
|
+
those records before grade B is possible. Caller-reported and plugin-observed
|
|
171
|
+
totals cannot establish grade A/B proof.
|
|
172
|
+
- `get_value_proof`: fetch and cryptographically verify the signed, token-only
|
|
173
|
+
evidence behind a qualified `potential_savings` estimate against
|
|
174
|
+
`/.well-known/remembrance-value-proof-keys.json`. A successful tool result
|
|
175
|
+
includes `signature_verified: true` and `verification_key_id`. The estimate is omitted unless
|
|
176
|
+
the exact skill version, model revision, reasoning effort, task stage,
|
|
177
|
+
complexity, bounded scope, risk, privacy, freshness, and positive-confidence
|
|
178
|
+
gates all pass. Those task-domain, stage, complexity, and bounded-scope cohort
|
|
179
|
+
fields are part of the signed payload. Public-skill proofs are anonymous reads; private-skill proofs
|
|
180
|
+
require an active query-capable API key from the same organization, but not
|
|
181
|
+
necessarily the key used for the original query, and never enter public
|
|
182
|
+
cohorts. Raw REST proof retrieval remains unchanged for clients that perform
|
|
183
|
+
their own verification.
|
|
104
184
|
- Feedback responses may include `next_step.submit_remembrance_payload` for
|
|
105
185
|
negative or substantive lessons. Call `submit_remembrance` with that payload,
|
|
106
186
|
plus `verified_attestation: true` when bootstrapped, to promote the lesson to
|
|
107
187
|
verified reusable evidence.
|
|
108
|
-
- Raw MCP clients do not have plugin Stop hooks. Before finishing,
|
|
109
|
-
|
|
110
|
-
|
|
188
|
+
- Raw MCP clients do not have plugin Stop hooks. Before finishing, self-check
|
|
189
|
+
for a missed query or unopened high match. Open that result now or submit
|
|
190
|
+
explicit poor-fit query feedback with a reason. Submit a `failure_report`
|
|
191
|
+
remembrance when you catch
|
|
192
|
+
your own mistake, the user catches one, CI/deploy fails, a security issue
|
|
193
|
+
surfaces, or you fix a release/versioning miss.
|
|
111
194
|
- `submit_remembrance`, `propose_skill_idea`, `submit_suggestion`.
|
|
112
195
|
- `submit_resource`, `submit_resource_review`.
|
|
113
196
|
- `request_attestation_challenge`, `register_agent_key` for adapters that
|
|
114
197
|
manage keys themselves.
|
|
115
198
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
199
|
+
The local MCP server uses the same TOFU identity to obtain a revocable 24-hour
|
|
200
|
+
economics session. Native plugins report a bounded completion automatically when
|
|
201
|
+
their host exposes enough lifecycle data. Raw MCP clients should call
|
|
202
|
+
`report_task_outcome` themselves after a selected result is used. Collection
|
|
203
|
+
mode never exposes USD values, prices, rebates, credits, subscriptions, or
|
|
204
|
+
payment instructions.
|
|
205
|
+
|
|
206
|
+
Provider labels such as `codex`, `cursor`, `claude`, and `openclaw` describe the
|
|
207
|
+
calling agent runtime. Independent agents should use `generic` or `other`.
|
|
119
208
|
|
|
120
209
|
Do not confuse `agent.provider` with `evidence.attestation.provider`.
|
|
121
210
|
`agent.provider` describes the calling runtime (`codex`, `cursor`, `claude`,
|
|
122
|
-
`generic`, `other`); attestation provider describes the signing key
|
|
123
|
-
(`claude_code`, `codex`, `cursor`, `other`).
|
|
211
|
+
`openclaw`, `generic`, `other`); attestation provider describes the signing key
|
|
212
|
+
family (`claude_code`, `codex`, `cursor`, `other`).
|
package/dist/server.js
CHANGED
|
@@ -75,6 +75,10 @@ function attestationEvidenceHashForRemembrance(payload) {
|
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// ../core/src/agent-guidance.ts
|
|
79
|
+
var REMEMBRANCE_QUERY_TOOL_DESCRIPTION = "Call before non-trivial service, API, tool, library, workflow, UI, review, test, security, or deployment work to find relevant Remembrance skills and resources. For short context-dependent follow-ups, infer the concrete task from the full conversation, preserve any plugin-supplied client_context.directive_id/runtime/trigger_reason, and query anyway. High matches should be fetched before custom work; possible and exploratory matches remain optional. Do not use for broad web search or one-off facts.";
|
|
80
|
+
var REMEMBRANCE_MCP_SERVER_INSTRUCTIONS = "Remembrance is shared operational memory for agents. BEFORE non-trivial service/API/tool/library/workflow/UI/review/test/security/deployment work, call query_skills to reuse proven skills and resources instead of rediscovering them. A local repository change still qualifies when it involves a reusable workflow or lesson; skip only genuinely trivial throwaway edits and one-off facts. For short follow-ups such as 'fix these issues', 'continue', or 'try again', infer the concrete task, domain, and constraints from the full conversation and still call query_skills; do not wait for the current prompt to repeat trigger keywords. Treat match_tier as a decision aid: for a high match, call get_skill or get_resource before custom work and pass the returned query_id/result_id so the surfaced-to-fetch funnel closes; possible and exploratory matches are optional. The response includes approximate context tokens, verified uses, and risk so you can weigh the detour. Honor query_skills.skill_access on every response. When policy is org_only, use only returned organization skills and never substitute bundled or live public skill references; if an organization key is configured and the query is unavailable, fail closed because the policy cannot be confirmed. AFTER query_skills, call submit_query_feedback once with one complete set of explicit good/partial/poor judgments using the returned query_id and result_id values; leave unrated results neutral, and remember that a poor query match is not the same as a globally bad skill. Reuse the same organization or anonymous auth scope as the query. AFTER you actually use a skill or resource, close the post-use loop with submit_feedback (useful true/false plus a one-line lesson and the originating query_id/result_id; it returns a ready submit_remembrance payload), then submit_remembrance if the lesson is reusable, or propose_skill_idea only if nothing fit and you built a new workflow. When delegating, pass the selected slug, query_id, and result_id to the subagent; it should fetch that result or run its own full-context query. Before finishing any reusable task, self-check for a missed query. If you catch your own mistake, the user catches one, CI/deploy fails, a security issue appears, or you fix a release/versioning miss, submit a failure_report remembrance even if no skill was used; raw MCP clients have no plugin Stop hook to remind you later. Attach evidence (reproduction detail, artifact hashes, or an attestation); evidence-less public reports wait in unverified intake until corroborated. Redact secrets, private URLs, credentials, raw logs, and proprietary content; submit summaries and hashes, not raw traces.";
|
|
81
|
+
|
|
78
82
|
// ../core/src/redaction.ts
|
|
79
83
|
var SECRET_PATTERN_SPECS = [
|
|
80
84
|
[
|
|
@@ -4165,6 +4169,9 @@ function boundedString(max) {
|
|
|
4165
4169
|
function finiteNumber() {
|
|
4166
4170
|
return external_exports.number().finite();
|
|
4167
4171
|
}
|
|
4172
|
+
function canonicalStringArray(values) {
|
|
4173
|
+
return [...values].sort().join("\0");
|
|
4174
|
+
}
|
|
4168
4175
|
function boundedJsonRecord(maxBytes = MAX_JSON_FIELD_BYTES) {
|
|
4169
4176
|
return external_exports.record(external_exports.unknown()).superRefine((value, ctx) => {
|
|
4170
4177
|
const byteLength = new TextEncoder().encode(JSON.stringify(value)).length;
|
|
@@ -4378,11 +4385,215 @@ var queryTaskSchema = external_exports.object({
|
|
|
4378
4385
|
summary: boundedString(MAX_LONG_TEXT_LENGTH),
|
|
4379
4386
|
constraints: external_exports.array(boundedString(MAX_SHORT_TEXT_LENGTH)).max(40).default([])
|
|
4380
4387
|
});
|
|
4388
|
+
var queryRuntimeSchema = external_exports.enum([
|
|
4389
|
+
"codex",
|
|
4390
|
+
"claude_code",
|
|
4391
|
+
"cursor",
|
|
4392
|
+
"openclaw",
|
|
4393
|
+
"other",
|
|
4394
|
+
"unknown"
|
|
4395
|
+
]);
|
|
4396
|
+
var queryDirectiveIdSchema = external_exports.string().regex(/^dir_[A-Za-z0-9_-]{16,80}$/);
|
|
4397
|
+
var queryClientContextSchema = external_exports.object({
|
|
4398
|
+
surface: external_exports.enum(["plugin_hook", "mcp", "rest", "unknown"]).default("unknown"),
|
|
4399
|
+
runtime: queryRuntimeSchema.optional(),
|
|
4400
|
+
trigger_reason: boundedString(MAX_SHORT_TEXT_LENGTH).optional(),
|
|
4401
|
+
directive_id: queryDirectiveIdSchema.optional()
|
|
4402
|
+
}).strict();
|
|
4403
|
+
var reasoningEffortSchema = external_exports.enum([
|
|
4404
|
+
"none",
|
|
4405
|
+
"minimal",
|
|
4406
|
+
"low",
|
|
4407
|
+
"medium",
|
|
4408
|
+
"high",
|
|
4409
|
+
"max",
|
|
4410
|
+
"unknown"
|
|
4411
|
+
]);
|
|
4412
|
+
var economicsTaskStageSchema = external_exports.enum([
|
|
4413
|
+
"planning",
|
|
4414
|
+
"implementation",
|
|
4415
|
+
"debugging",
|
|
4416
|
+
"review",
|
|
4417
|
+
"testing",
|
|
4418
|
+
"deployment",
|
|
4419
|
+
"research",
|
|
4420
|
+
"other",
|
|
4421
|
+
"unknown"
|
|
4422
|
+
]);
|
|
4423
|
+
var economicsTaskComplexitySchema = external_exports.enum([
|
|
4424
|
+
"low",
|
|
4425
|
+
"medium",
|
|
4426
|
+
"high",
|
|
4427
|
+
"unknown"
|
|
4428
|
+
]);
|
|
4429
|
+
var economicsMeasurementCapabilitySchema = external_exports.enum([
|
|
4430
|
+
"token_usage",
|
|
4431
|
+
"cache_usage",
|
|
4432
|
+
"reasoning_tokens",
|
|
4433
|
+
"latency",
|
|
4434
|
+
"provider_response_id",
|
|
4435
|
+
"observed_model_revision"
|
|
4436
|
+
]);
|
|
4437
|
+
var boundedScopeCountSchema = external_exports.number().int().min(0).max(1e5);
|
|
4438
|
+
var economicsContextSchema = external_exports.object({
|
|
4439
|
+
runtime: queryRuntimeSchema,
|
|
4440
|
+
runtime_version: boundedString(MAX_SHORT_TEXT_LENGTH).optional(),
|
|
4441
|
+
requested_model: boundedString(MAX_SHORT_TEXT_LENGTH).optional(),
|
|
4442
|
+
observed_model_revision: boundedString(MAX_SHORT_TEXT_LENGTH).optional(),
|
|
4443
|
+
reasoning_effort: reasoningEffortSchema.default("unknown"),
|
|
4444
|
+
task_stage: economicsTaskStageSchema.default("unknown"),
|
|
4445
|
+
complexity: economicsTaskComplexitySchema.default("unknown"),
|
|
4446
|
+
scope: external_exports.object({
|
|
4447
|
+
file_count: boundedScopeCountSchema.optional(),
|
|
4448
|
+
service_count: boundedScopeCountSchema.optional(),
|
|
4449
|
+
artifact_count: boundedScopeCountSchema.optional(),
|
|
4450
|
+
expected_step_count: boundedScopeCountSchema.optional()
|
|
4451
|
+
}).strict().default({}),
|
|
4452
|
+
measurement_capabilities: external_exports.array(economicsMeasurementCapabilitySchema).max(economicsMeasurementCapabilitySchema.options.length).default([])
|
|
4453
|
+
}).strict();
|
|
4454
|
+
var agentDirectiveShownEventSchema = external_exports.object({
|
|
4455
|
+
event: external_exports.literal("shown"),
|
|
4456
|
+
directive_id: queryDirectiveIdSchema,
|
|
4457
|
+
surface: external_exports.literal("plugin_hook"),
|
|
4458
|
+
runtime: queryRuntimeSchema,
|
|
4459
|
+
trigger_reason: boundedString(MAX_SHORT_TEXT_LENGTH)
|
|
4460
|
+
}).strict();
|
|
4461
|
+
var agentDirectiveFollowedEventSchema = external_exports.object({
|
|
4462
|
+
event: external_exports.literal("followed"),
|
|
4463
|
+
directive_id: queryDirectiveIdSchema,
|
|
4464
|
+
query_id: boundedString(MAX_SHORT_TEXT_LENGTH)
|
|
4465
|
+
}).strict();
|
|
4466
|
+
var agentDirectiveEventRequestSchema = external_exports.discriminatedUnion("event", [
|
|
4467
|
+
agentDirectiveShownEventSchema,
|
|
4468
|
+
agentDirectiveFollowedEventSchema
|
|
4469
|
+
]);
|
|
4470
|
+
var MAX_AGENT_QUERY_RESULTS_PER_TYPE = 20;
|
|
4381
4471
|
var agentQueryRequestSchema = external_exports.object({
|
|
4382
4472
|
agent: agentSchema.optional(),
|
|
4383
4473
|
task: queryTaskSchema,
|
|
4384
|
-
|
|
4474
|
+
// Caller-reported analytics only. This never contributes identity, trust,
|
|
4475
|
+
// authorization, or ranking weight; transports overwrite `surface` when
|
|
4476
|
+
// they know it authoritatively.
|
|
4477
|
+
client_context: queryClientContextSchema.optional(),
|
|
4478
|
+
// Privacy-bounded value measurement context. Prompts, paths, URLs, source,
|
|
4479
|
+
// transcripts, and outputs are intentionally not representable here.
|
|
4480
|
+
economics_context: economicsContextSchema.optional(),
|
|
4481
|
+
limit: external_exports.number().int().min(1).max(MAX_AGENT_QUERY_RESULTS_PER_TYPE).default(5)
|
|
4482
|
+
});
|
|
4483
|
+
var tokenUsageSchema = external_exports.object({
|
|
4484
|
+
uncached_input_tokens: external_exports.number().int().min(0).max(1e7),
|
|
4485
|
+
cache_read_tokens: external_exports.number().int().min(0).max(1e7).default(0),
|
|
4486
|
+
cache_write_tokens: external_exports.number().int().min(0).max(1e7).default(0),
|
|
4487
|
+
visible_output_tokens: external_exports.number().int().min(0).max(1e7),
|
|
4488
|
+
reasoning_tokens: external_exports.number().int().min(0).max(1e7).default(0)
|
|
4489
|
+
}).strict();
|
|
4490
|
+
var economicsMeasurementSourceSchema = external_exports.enum([
|
|
4491
|
+
"provider_metered",
|
|
4492
|
+
"gateway_metered",
|
|
4493
|
+
"plugin_observed",
|
|
4494
|
+
"agent_reported",
|
|
4495
|
+
"controlled_eval"
|
|
4496
|
+
]);
|
|
4497
|
+
var economicsMeteringReferenceSchema = external_exports.object({
|
|
4498
|
+
adapter: external_exports.literal("vercel_ai_gateway"),
|
|
4499
|
+
generation_ids: external_exports.array(
|
|
4500
|
+
boundedString(MAX_SHORT_TEXT_LENGTH).regex(
|
|
4501
|
+
/^gen_[A-Za-z0-9]+$/,
|
|
4502
|
+
"Vercel generation identifiers must use the gen_ format"
|
|
4503
|
+
)
|
|
4504
|
+
).min(1).max(8)
|
|
4505
|
+
}).strict().superRefine((value, ctx) => {
|
|
4506
|
+
if (new Set(value.generation_ids).size !== value.generation_ids.length) {
|
|
4507
|
+
ctx.addIssue({
|
|
4508
|
+
code: external_exports.ZodIssueCode.custom,
|
|
4509
|
+
message: "Each generation_id may appear only once",
|
|
4510
|
+
path: ["generation_ids"]
|
|
4511
|
+
});
|
|
4512
|
+
}
|
|
4385
4513
|
});
|
|
4514
|
+
var taskOutcomeStatusSchema = external_exports.enum(["completed", "abandoned"]);
|
|
4515
|
+
var economicsSessionProviderSchema = attestationProviderSchema.exclude([
|
|
4516
|
+
"org_api_key"
|
|
4517
|
+
]);
|
|
4518
|
+
var economicsOutcomeAttestationSchema = external_exports.object({
|
|
4519
|
+
version: external_exports.literal("v2").default("v2"),
|
|
4520
|
+
provider: economicsSessionProviderSchema,
|
|
4521
|
+
challenge_id: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4522
|
+
key_id: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4523
|
+
algorithm: external_exports.literal("ed25519").default("ed25519"),
|
|
4524
|
+
issued_at: external_exports.string().datetime(),
|
|
4525
|
+
expires_at: external_exports.string().datetime(),
|
|
4526
|
+
signature: boundedString(MAX_LONG_TEXT_LENGTH)
|
|
4527
|
+
}).strict();
|
|
4528
|
+
var agentTaskOutcomeRequestSchema = external_exports.object({
|
|
4529
|
+
query_id: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4530
|
+
result_ids: external_exports.array(boundedString(MAX_SHORT_TEXT_LENGTH)).max(3).default([]),
|
|
4531
|
+
estimate_id: boundedString(MAX_SHORT_TEXT_LENGTH).nullable().optional(),
|
|
4532
|
+
bundle_id: boundedString(MAX_SHORT_TEXT_LENGTH).nullable().optional(),
|
|
4533
|
+
status: taskOutcomeStatusSchema,
|
|
4534
|
+
success: external_exports.boolean().nullable().optional(),
|
|
4535
|
+
latency_ms: external_exports.number().int().min(0).max(864e5).nullable().optional(),
|
|
4536
|
+
token_usage: tokenUsageSchema.nullable().optional(),
|
|
4537
|
+
observed_model_revision: boundedString(MAX_SHORT_TEXT_LENGTH).nullable().optional(),
|
|
4538
|
+
reasoning_effort: reasoningEffortSchema.optional(),
|
|
4539
|
+
provider_response_ids: external_exports.array(boundedString(MAX_SHORT_TEXT_LENGTH)).max(8).default([]),
|
|
4540
|
+
metering_reference: economicsMeteringReferenceSchema.nullable().optional(),
|
|
4541
|
+
measurement_source: economicsMeasurementSourceSchema,
|
|
4542
|
+
idempotency_key: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4543
|
+
attestation: economicsOutcomeAttestationSchema.nullable().optional()
|
|
4544
|
+
}).strict().superRefine((value, ctx) => {
|
|
4545
|
+
if ((value.measurement_source === "provider_metered" || value.measurement_source === "gateway_metered") && value.provider_response_ids.length === 0 && !value.metering_reference) {
|
|
4546
|
+
ctx.addIssue({
|
|
4547
|
+
code: external_exports.ZodIssueCode.custom,
|
|
4548
|
+
message: "Metered outcomes require a provider response identifier",
|
|
4549
|
+
path: ["provider_response_ids"]
|
|
4550
|
+
});
|
|
4551
|
+
}
|
|
4552
|
+
if (value.metering_reference && value.provider_response_ids.length > 0 && canonicalStringArray(value.metering_reference.generation_ids) !== canonicalStringArray(value.provider_response_ids)) {
|
|
4553
|
+
ctx.addIssue({
|
|
4554
|
+
code: external_exports.ZodIssueCode.custom,
|
|
4555
|
+
message: "metering_reference generation_ids must match provider_response_ids when both are supplied",
|
|
4556
|
+
path: ["metering_reference", "generation_ids"]
|
|
4557
|
+
});
|
|
4558
|
+
}
|
|
4559
|
+
if (new Set(value.result_ids).size !== value.result_ids.length) {
|
|
4560
|
+
ctx.addIssue({
|
|
4561
|
+
code: external_exports.ZodIssueCode.custom,
|
|
4562
|
+
message: "Each result_id may appear only once",
|
|
4563
|
+
path: ["result_ids"]
|
|
4564
|
+
});
|
|
4565
|
+
}
|
|
4566
|
+
});
|
|
4567
|
+
var economicsSessionChallengeSchema = external_exports.object({
|
|
4568
|
+
action: external_exports.literal("challenge"),
|
|
4569
|
+
provider: economicsSessionProviderSchema,
|
|
4570
|
+
key_id: boundedString(MAX_SHORT_TEXT_LENGTH)
|
|
4571
|
+
}).strict();
|
|
4572
|
+
var economicsSessionExchangeSchema = external_exports.object({
|
|
4573
|
+
action: external_exports.literal("exchange"),
|
|
4574
|
+
provider: economicsSessionProviderSchema,
|
|
4575
|
+
key_id: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4576
|
+
challenge_id: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4577
|
+
signature: boundedString(MAX_LONG_TEXT_LENGTH)
|
|
4578
|
+
}).strict();
|
|
4579
|
+
var economicsSessionRequestSchema = external_exports.discriminatedUnion("action", [
|
|
4580
|
+
economicsSessionChallengeSchema,
|
|
4581
|
+
economicsSessionExchangeSchema
|
|
4582
|
+
]);
|
|
4583
|
+
var agentPrincipalRegistrationRequestSchema = external_exports.object({
|
|
4584
|
+
display_name: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4585
|
+
provider: agentProviderSchema,
|
|
4586
|
+
runtime_version: boundedString(MAX_SHORT_TEXT_LENGTH).nullable().optional(),
|
|
4587
|
+
parent_principal_id: boundedString(MAX_SHORT_TEXT_LENGTH).nullable().optional()
|
|
4588
|
+
}).strict();
|
|
4589
|
+
var agentPrincipalUpdateRequestSchema = external_exports.object({
|
|
4590
|
+
principal_id: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4591
|
+
action: external_exports.enum(["deactivate", "reactivate"])
|
|
4592
|
+
}).strict();
|
|
4593
|
+
var agentPrincipalKeyBindingRequestSchema = external_exports.object({
|
|
4594
|
+
principal_id: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4595
|
+
api_key_id: boundedString(MAX_SHORT_TEXT_LENGTH)
|
|
4596
|
+
}).strict();
|
|
4386
4597
|
var remembranceTaskSchema = external_exports.object({
|
|
4387
4598
|
domain: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4388
4599
|
summary: boundedString(MAX_LONG_TEXT_LENGTH),
|
|
@@ -4622,8 +4833,10 @@ var attestationKeyRegistrationRequestSchema = external_exports.object({
|
|
|
4622
4833
|
});
|
|
4623
4834
|
}
|
|
4624
4835
|
});
|
|
4625
|
-
var
|
|
4836
|
+
var agentFeedbackRequestBaseSchema = external_exports.object({
|
|
4626
4837
|
skill_slug: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4838
|
+
query_id: boundedString(MAX_SHORT_TEXT_LENGTH).optional(),
|
|
4839
|
+
result_id: boundedString(MAX_SHORT_TEXT_LENGTH).optional(),
|
|
4627
4840
|
useful: external_exports.boolean(),
|
|
4628
4841
|
lesson: external_exports.string().max(MAX_LONG_TEXT_LENGTH).nullable().optional(),
|
|
4629
4842
|
rating: external_exports.number().int().min(1).max(5).nullable().optional(),
|
|
@@ -4631,6 +4844,74 @@ var agentFeedbackRequestSchema = external_exports.object({
|
|
|
4631
4844
|
idempotency_key: boundedString(MAX_SHORT_TEXT_LENGTH).optional(),
|
|
4632
4845
|
evidence: evidenceSchema.default({ artifact_hashes: [] })
|
|
4633
4846
|
});
|
|
4847
|
+
var agentFeedbackRequestSchema = agentFeedbackRequestBaseSchema.superRefine((value, ctx) => {
|
|
4848
|
+
if (Boolean(value.query_id) !== Boolean(value.result_id)) {
|
|
4849
|
+
ctx.addIssue({
|
|
4850
|
+
code: external_exports.ZodIssueCode.custom,
|
|
4851
|
+
message: "query_id and result_id must be supplied together",
|
|
4852
|
+
path: value.query_id ? ["result_id"] : ["query_id"]
|
|
4853
|
+
});
|
|
4854
|
+
}
|
|
4855
|
+
});
|
|
4856
|
+
var queryResultFitSchema = external_exports.enum(["good", "partial", "poor"]);
|
|
4857
|
+
var queryFeedbackReasonSchema = external_exports.enum([
|
|
4858
|
+
"wrong_domain",
|
|
4859
|
+
"wrong_task",
|
|
4860
|
+
"constraint_conflict",
|
|
4861
|
+
"wrong_task_stage",
|
|
4862
|
+
"too_generic",
|
|
4863
|
+
"too_specific",
|
|
4864
|
+
"duplicate",
|
|
4865
|
+
"stale_metadata",
|
|
4866
|
+
"missing_capability",
|
|
4867
|
+
"other"
|
|
4868
|
+
]);
|
|
4869
|
+
var agentQueryFeedbackResultSchema = external_exports.object({
|
|
4870
|
+
result_id: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4871
|
+
fit: queryResultFitSchema,
|
|
4872
|
+
reasons: external_exports.array(queryFeedbackReasonSchema).max(8).default([]),
|
|
4873
|
+
note: external_exports.string().max(1e3).transform((value) => value.trim()).nullable().optional()
|
|
4874
|
+
}).strict().superRefine((value, ctx) => {
|
|
4875
|
+
if (value.fit === "poor" && value.reasons.length === 0) {
|
|
4876
|
+
ctx.addIssue({
|
|
4877
|
+
code: external_exports.ZodIssueCode.custom,
|
|
4878
|
+
message: "Poor matches require at least one reason",
|
|
4879
|
+
path: ["reasons"]
|
|
4880
|
+
});
|
|
4881
|
+
}
|
|
4882
|
+
});
|
|
4883
|
+
var agentQueryFeedbackRequestSchema = external_exports.object({
|
|
4884
|
+
query_id: boundedString(MAX_SHORT_TEXT_LENGTH),
|
|
4885
|
+
overall_fit: external_exports.enum(["good", "partial", "none"]),
|
|
4886
|
+
results: external_exports.array(agentQueryFeedbackResultSchema).max(20).default([]),
|
|
4887
|
+
missing_capability: external_exports.string().max(2e3).transform((value) => value.trim()).nullable().optional(),
|
|
4888
|
+
agent: agentSchema.optional(),
|
|
4889
|
+
idempotency_key: boundedString(MAX_SHORT_TEXT_LENGTH).optional(),
|
|
4890
|
+
evidence: evidenceSchema.default({ artifact_hashes: [] })
|
|
4891
|
+
}).strict().superRefine((value, ctx) => {
|
|
4892
|
+
if (value.results.length === 0 && value.overall_fit !== "none") {
|
|
4893
|
+
ctx.addIssue({
|
|
4894
|
+
code: external_exports.ZodIssueCode.custom,
|
|
4895
|
+
message: "At least one result verdict is required unless nothing fit",
|
|
4896
|
+
path: ["results"]
|
|
4897
|
+
});
|
|
4898
|
+
}
|
|
4899
|
+
const resultIds = value.results.map((result) => result.result_id);
|
|
4900
|
+
if (new Set(resultIds).size !== resultIds.length) {
|
|
4901
|
+
ctx.addIssue({
|
|
4902
|
+
code: external_exports.ZodIssueCode.custom,
|
|
4903
|
+
message: "Each result_id may appear only once",
|
|
4904
|
+
path: ["results"]
|
|
4905
|
+
});
|
|
4906
|
+
}
|
|
4907
|
+
if (value.overall_fit === "none" && value.results.some((result) => result.fit !== "poor")) {
|
|
4908
|
+
ctx.addIssue({
|
|
4909
|
+
code: external_exports.ZodIssueCode.custom,
|
|
4910
|
+
message: "When nothing fit, every rated result must be marked poor",
|
|
4911
|
+
path: ["results"]
|
|
4912
|
+
});
|
|
4913
|
+
}
|
|
4914
|
+
});
|
|
4634
4915
|
var adminReviewActionValueSchema = external_exports.enum([
|
|
4635
4916
|
...verifierActionSchema.options,
|
|
4636
4917
|
"delete"
|
|
@@ -4645,6 +4926,183 @@ var adminReviewActionSchema = external_exports.object({
|
|
|
4645
4926
|
var siteUrl = "https://remembrance.dev";
|
|
4646
4927
|
var feedbackUrl = `${siteUrl}/api/v1/agent/remembrances`;
|
|
4647
4928
|
|
|
4929
|
+
// ../core/src/skill-value.ts
|
|
4930
|
+
import {
|
|
4931
|
+
createPublicKey,
|
|
4932
|
+
verify
|
|
4933
|
+
} from "node:crypto";
|
|
4934
|
+
var tokenSavingsRangeSchema = external_exports.object({
|
|
4935
|
+
low: external_exports.number().int(),
|
|
4936
|
+
median: external_exports.number().int(),
|
|
4937
|
+
high: external_exports.number().int()
|
|
4938
|
+
}).strict();
|
|
4939
|
+
var valueProofScopeSchema = external_exports.object({
|
|
4940
|
+
file_count: external_exports.number().int().min(0).max(1e5).optional(),
|
|
4941
|
+
service_count: external_exports.number().int().min(0).max(1e5).optional(),
|
|
4942
|
+
artifact_count: external_exports.number().int().min(0).max(1e5).optional(),
|
|
4943
|
+
expected_step_count: external_exports.number().int().min(0).max(1e5).optional()
|
|
4944
|
+
}).strict();
|
|
4945
|
+
var valueProofKeyIdSchema = external_exports.string().min(1).max(512);
|
|
4946
|
+
var VALUE_PROOF_ISSUED_AT_CLOCK_SKEW_MS = 5 * 60 * 1e3;
|
|
4947
|
+
var publicValueProofPayloadSchema = external_exports.object({
|
|
4948
|
+
proof_id: external_exports.string().min(1).max(512),
|
|
4949
|
+
proof_scope: external_exports.enum(["public", "organization"]),
|
|
4950
|
+
target_version_ids: external_exports.array(external_exports.string().min(1).max(512)).min(1).max(3),
|
|
4951
|
+
target_slugs: external_exports.array(external_exports.string().min(1).max(512)).min(1).max(3),
|
|
4952
|
+
runtime: external_exports.string().min(1).max(512),
|
|
4953
|
+
runtime_version: external_exports.string().min(1).max(512),
|
|
4954
|
+
requested_model: external_exports.string().min(1).max(512),
|
|
4955
|
+
model_revision: external_exports.string().min(1).max(512),
|
|
4956
|
+
reasoning_effort: external_exports.string().min(1).max(128),
|
|
4957
|
+
task_domain: external_exports.string().min(1).max(512),
|
|
4958
|
+
task_stage: economicsTaskStageSchema,
|
|
4959
|
+
complexity: economicsTaskComplexitySchema,
|
|
4960
|
+
scope: valueProofScopeSchema,
|
|
4961
|
+
context_tokens: external_exports.number().int().nonnegative(),
|
|
4962
|
+
estimated_saved: tokenSavingsRangeSchema,
|
|
4963
|
+
confidence_interval_90: external_exports.object({ lower: external_exports.number().int(), upper: external_exports.number().int() }).strict(),
|
|
4964
|
+
success_rate_delta: external_exports.number().finite().nullable(),
|
|
4965
|
+
latency_delta_ms: external_exports.number().finite().nullable(),
|
|
4966
|
+
evidence_count: external_exports.number().int().nonnegative(),
|
|
4967
|
+
scenario_count: external_exports.number().int().nonnegative(),
|
|
4968
|
+
proof_grade: external_exports.enum(["A", "B"]),
|
|
4969
|
+
estimator_version: external_exports.string().min(1).max(512),
|
|
4970
|
+
methodology: external_exports.enum(["paired_metered", "observed_metered"]),
|
|
4971
|
+
evidence_digest: external_exports.string().min(1).max(512),
|
|
4972
|
+
issued_at: external_exports.string().datetime(),
|
|
4973
|
+
calibrated_at: external_exports.string().datetime(),
|
|
4974
|
+
expires_at: external_exports.string().datetime()
|
|
4975
|
+
}).strict().superRefine((payload, context) => {
|
|
4976
|
+
if (payload.target_version_ids.length !== payload.target_slugs.length) {
|
|
4977
|
+
context.addIssue({
|
|
4978
|
+
code: "custom",
|
|
4979
|
+
message: "Value proof targets are inconsistent.",
|
|
4980
|
+
path: ["target_slugs"]
|
|
4981
|
+
});
|
|
4982
|
+
}
|
|
4983
|
+
if (payload.estimated_saved.low > payload.estimated_saved.median || payload.estimated_saved.median > payload.estimated_saved.high) {
|
|
4984
|
+
context.addIssue({
|
|
4985
|
+
code: "custom",
|
|
4986
|
+
message: "Value proof savings range is not ordered.",
|
|
4987
|
+
path: ["estimated_saved"]
|
|
4988
|
+
});
|
|
4989
|
+
}
|
|
4990
|
+
if (payload.confidence_interval_90.lower > payload.confidence_interval_90.upper) {
|
|
4991
|
+
context.addIssue({
|
|
4992
|
+
code: "custom",
|
|
4993
|
+
message: "Value proof confidence interval is not ordered.",
|
|
4994
|
+
path: ["confidence_interval_90"]
|
|
4995
|
+
});
|
|
4996
|
+
}
|
|
4997
|
+
const calibratedAt = Date.parse(payload.calibrated_at);
|
|
4998
|
+
const issuedAt = Date.parse(payload.issued_at);
|
|
4999
|
+
const expiresAt = Date.parse(payload.expires_at);
|
|
5000
|
+
if (calibratedAt > issuedAt || issuedAt >= expiresAt) {
|
|
5001
|
+
context.addIssue({
|
|
5002
|
+
code: "custom",
|
|
5003
|
+
message: "Value proof timestamps are inconsistent.",
|
|
5004
|
+
path: ["issued_at"]
|
|
5005
|
+
});
|
|
5006
|
+
}
|
|
5007
|
+
});
|
|
5008
|
+
var signedValueProofResponseSchema = external_exports.object({
|
|
5009
|
+
payload: publicValueProofPayloadSchema,
|
|
5010
|
+
signature: external_exports.string().regex(/^[A-Za-z0-9_-]+$/).max(512),
|
|
5011
|
+
key_id: valueProofKeyIdSchema,
|
|
5012
|
+
algorithm: external_exports.literal("Ed25519")
|
|
5013
|
+
}).strict();
|
|
5014
|
+
var valueProofPublicKeySchema = external_exports.object({
|
|
5015
|
+
kid: valueProofKeyIdSchema,
|
|
5016
|
+
kty: external_exports.literal("OKP"),
|
|
5017
|
+
crv: external_exports.literal("Ed25519"),
|
|
5018
|
+
x: external_exports.string().min(1).max(512),
|
|
5019
|
+
alg: external_exports.literal("EdDSA").optional(),
|
|
5020
|
+
use: external_exports.literal("sig").optional()
|
|
5021
|
+
}).passthrough();
|
|
5022
|
+
var valueProofPublicKeySetSchema = external_exports.object({
|
|
5023
|
+
keys: external_exports.array(valueProofPublicKeySchema).max(32)
|
|
5024
|
+
}).strict();
|
|
5025
|
+
var ValueProofVerificationError = class extends Error {
|
|
5026
|
+
constructor(message, code) {
|
|
5027
|
+
super(message);
|
|
5028
|
+
this.code = code;
|
|
5029
|
+
this.name = "ValueProofVerificationError";
|
|
5030
|
+
}
|
|
5031
|
+
code;
|
|
5032
|
+
};
|
|
5033
|
+
function verifySignedValueProof(proofInput, keySetInput, now = /* @__PURE__ */ new Date()) {
|
|
5034
|
+
let proof;
|
|
5035
|
+
let keySet;
|
|
5036
|
+
try {
|
|
5037
|
+
proof = signedValueProofResponseSchema.parse(proofInput);
|
|
5038
|
+
keySet = valueProofPublicKeySetSchema.parse(keySetInput);
|
|
5039
|
+
} catch {
|
|
5040
|
+
throw new ValueProofVerificationError(
|
|
5041
|
+
"Value proof or verification key set is malformed.",
|
|
5042
|
+
"malformed"
|
|
5043
|
+
);
|
|
5044
|
+
}
|
|
5045
|
+
const issuedAt = Date.parse(proof.payload.issued_at);
|
|
5046
|
+
const expiresAt = Date.parse(proof.payload.expires_at);
|
|
5047
|
+
if (issuedAt > now.getTime() + VALUE_PROOF_ISSUED_AT_CLOCK_SKEW_MS || expiresAt <= now.getTime()) {
|
|
5048
|
+
throw new ValueProofVerificationError(
|
|
5049
|
+
"Value proof is expired or not yet valid.",
|
|
5050
|
+
"not_current"
|
|
5051
|
+
);
|
|
5052
|
+
}
|
|
5053
|
+
const jwk = keySet.keys.find((candidate) => candidate.kid === proof.key_id);
|
|
5054
|
+
if (!jwk) {
|
|
5055
|
+
throw new ValueProofVerificationError(
|
|
5056
|
+
`Value proof verification key is unavailable: ${proof.key_id}`,
|
|
5057
|
+
"key_unavailable"
|
|
5058
|
+
);
|
|
5059
|
+
}
|
|
5060
|
+
if (Buffer.from(jwk.x, "base64url").byteLength !== 32) {
|
|
5061
|
+
throw new ValueProofVerificationError(
|
|
5062
|
+
"Value proof verification key is invalid.",
|
|
5063
|
+
"invalid_key"
|
|
5064
|
+
);
|
|
5065
|
+
}
|
|
5066
|
+
const signature = Buffer.from(proof.signature, "base64url");
|
|
5067
|
+
if (signature.byteLength !== 64) {
|
|
5068
|
+
throw new ValueProofVerificationError(
|
|
5069
|
+
"Value proof signature is malformed.",
|
|
5070
|
+
"malformed"
|
|
5071
|
+
);
|
|
5072
|
+
}
|
|
5073
|
+
const verified = verify(
|
|
5074
|
+
null,
|
|
5075
|
+
Buffer.from(canonicalJson(proof.payload)),
|
|
5076
|
+
createPublicKey({
|
|
5077
|
+
key: { kty: "OKP", crv: "Ed25519", x: jwk.x },
|
|
5078
|
+
format: "jwk"
|
|
5079
|
+
}),
|
|
5080
|
+
signature
|
|
5081
|
+
);
|
|
5082
|
+
if (!verified) {
|
|
5083
|
+
throw new ValueProofVerificationError(
|
|
5084
|
+
"Value proof signature verification failed.",
|
|
5085
|
+
"invalid_signature"
|
|
5086
|
+
);
|
|
5087
|
+
}
|
|
5088
|
+
return {
|
|
5089
|
+
...proof,
|
|
5090
|
+
signature_verified: true,
|
|
5091
|
+
verification_key_id: proof.key_id
|
|
5092
|
+
};
|
|
5093
|
+
}
|
|
5094
|
+
async function verifySignedValueProofWithKeyRefresh(proofInput, loadKeySet) {
|
|
5095
|
+
const keySet = await loadKeySet(false);
|
|
5096
|
+
try {
|
|
5097
|
+
return verifySignedValueProof(proofInput, keySet);
|
|
5098
|
+
} catch (error) {
|
|
5099
|
+
if (error.code !== "key_unavailable") {
|
|
5100
|
+
throw error;
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
return verifySignedValueProof(proofInput, await loadKeySet(true));
|
|
5104
|
+
}
|
|
5105
|
+
|
|
4648
5106
|
// ../core/src/verifier.ts
|
|
4649
5107
|
var duplicateCandidateSchema = external_exports.object({
|
|
4650
5108
|
type: external_exports.enum(["skill", "resource", "remembrance"]),
|
|
@@ -6053,7 +6511,12 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
6053
6511
|
|
|
6054
6512
|
// src/tool-definitions.ts
|
|
6055
6513
|
var getBySlugSchema = external_exports.object({
|
|
6056
|
-
slug: external_exports.string().min(1).describe("Public skill or resource slug.")
|
|
6514
|
+
slug: external_exports.string().min(1).describe("Public skill or resource slug."),
|
|
6515
|
+
query_id: external_exports.string().min(1).optional().describe("Originating query_id, when this result came from query_skills."),
|
|
6516
|
+
result_id: external_exports.string().min(1).optional().describe("Originating result_id, when available.")
|
|
6517
|
+
});
|
|
6518
|
+
var getValueProofSchema = external_exports.object({
|
|
6519
|
+
id: external_exports.string().min(1).describe("Value proof id returned with potential_savings.")
|
|
6057
6520
|
});
|
|
6058
6521
|
var bootstrapAgentIdentitySchema = external_exports.object({
|
|
6059
6522
|
subject: external_exports.string().min(1).describe("Stable agent identity, for example codex:user@example.com."),
|
|
@@ -6064,10 +6527,18 @@ var bootstrapAgentIdentitySchema = external_exports.object({
|
|
|
6064
6527
|
key_path: external_exports.string().min(1).optional().describe("Override key file path. Defaults to XDG config."),
|
|
6065
6528
|
force_rotate: external_exports.boolean().default(false).describe("Generate and register a new key even when one exists.")
|
|
6066
6529
|
});
|
|
6067
|
-
var feedbackToolSchema =
|
|
6530
|
+
var feedbackToolSchema = agentFeedbackRequestBaseSchema.extend({
|
|
6068
6531
|
verified_attestation: external_exports.boolean().default(false).describe(
|
|
6069
6532
|
"When true, sign the feedback with the local TOFU key if present."
|
|
6070
6533
|
)
|
|
6534
|
+
}).superRefine((value, ctx) => {
|
|
6535
|
+
if (Boolean(value.query_id) !== Boolean(value.result_id)) {
|
|
6536
|
+
ctx.addIssue({
|
|
6537
|
+
code: external_exports.ZodIssueCode.custom,
|
|
6538
|
+
message: "query_id and result_id must be supplied together",
|
|
6539
|
+
path: value.query_id ? ["result_id"] : ["query_id"]
|
|
6540
|
+
});
|
|
6541
|
+
}
|
|
6071
6542
|
});
|
|
6072
6543
|
var remembranceToolSchema = remembrancePayloadSchema.extend({
|
|
6073
6544
|
verified_attestation: external_exports.boolean().default(false).describe(
|
|
@@ -6077,20 +6548,20 @@ var remembranceToolSchema = remembrancePayloadSchema.extend({
|
|
|
6077
6548
|
var toolDefinitions = [
|
|
6078
6549
|
tool(
|
|
6079
6550
|
"query_skills",
|
|
6080
|
-
|
|
6551
|
+
REMEMBRANCE_QUERY_TOOL_DESCRIPTION,
|
|
6081
6552
|
"/api/v1/agent/query",
|
|
6082
6553
|
agentQueryRequestSchema
|
|
6083
6554
|
),
|
|
6084
6555
|
tool(
|
|
6085
6556
|
"get_skill",
|
|
6086
|
-
"Fetch a known
|
|
6557
|
+
"Fetch a known skill by slug after query_skills returns it. Pass query_id and result_id from that response so Remembrance can measure whether surfaced guidance was opened. Do not guess private or inactive slugs.",
|
|
6087
6558
|
"/api/v1/skills/{slug}",
|
|
6088
6559
|
getBySlugSchema,
|
|
6089
6560
|
"GET"
|
|
6090
6561
|
),
|
|
6091
6562
|
tool(
|
|
6092
6563
|
"get_resource",
|
|
6093
|
-
"Fetch a known
|
|
6564
|
+
"Fetch a known resource by slug after query_skills returns it. Pass query_id and result_id from that response so Remembrance can measure whether surfaced guidance was opened. Do not use for arbitrary URL fetching.",
|
|
6094
6565
|
"/api/v1/resources/{slug}",
|
|
6095
6566
|
getBySlugSchema,
|
|
6096
6567
|
"GET"
|
|
@@ -6103,10 +6574,29 @@ var toolDefinitions = [
|
|
|
6103
6574
|
),
|
|
6104
6575
|
tool(
|
|
6105
6576
|
"submit_feedback",
|
|
6106
|
-
"Submit minimal skill feedback. If the response includes next_step.submit_remembrance_payload, call submit_remembrance to promote substantive feedback to rich evidence. For self-corrections or CI/deploy/release misses, use submit_remembrance with type failure_report.",
|
|
6577
|
+
"Submit minimal post-use skill feedback. When the skill came from query_skills, pass its query_id and result_id to close the surfaced-to-use funnel. If the response includes next_step.submit_remembrance_payload, call submit_remembrance to promote substantive feedback to rich evidence. For self-corrections or CI/deploy/release misses, use submit_remembrance with type failure_report.",
|
|
6107
6578
|
"/api/v1/agent/feedback",
|
|
6108
6579
|
feedbackToolSchema
|
|
6109
6580
|
),
|
|
6581
|
+
tool(
|
|
6582
|
+
"submit_query_feedback",
|
|
6583
|
+
"Submit one complete set of explicit good, partial, or poor judgments for result_id values from one query_skills call, using the same auth scope as that query. Unrated results stay neutral. An identical retry is safe, but changed later judgments conflict. Same-query better/worse labels can train retrieval without changing global skill usefulness; use submit_feedback only after actually using a skill.",
|
|
6584
|
+
"/api/v1/agent/query-feedback",
|
|
6585
|
+
agentQueryFeedbackRequestSchema
|
|
6586
|
+
),
|
|
6587
|
+
tool(
|
|
6588
|
+
"report_task_outcome",
|
|
6589
|
+
"Report completion or abandonment for a query. Remembrance accepts one terminal outcome per query; retry the same report with the same idempotency_key, and do not submit a different later outcome. Include only result_ids listed in task_outcome.eligible_result_ids; each result and bundle also carries task_outcome_eligible. When two or three selected skills exactly match a returned skill_bundles entry, include its bundle_id for value attribution; other combinations are accepted as funnel telemetry but do not train a skill or bundle cohort. Include bounded token totals only when the runtime exposes them. For Vercel AI Gateway work, include metering_reference.adapter=vercel_ai_gateway and every gen_ generation ID used by the task (maximum eight); Remembrance retrieves authoritative usage asynchronously, and caller totals never establish proof trust. Never send prompts, outputs, source paths, private URLs, transcripts, or proprietary task content. Completion without token counts still closes the funnel but cannot establish metered savings proof.",
|
|
6590
|
+
"/api/v1/agent/task-outcomes",
|
|
6591
|
+
agentTaskOutcomeRequestSchema
|
|
6592
|
+
),
|
|
6593
|
+
tool(
|
|
6594
|
+
"get_value_proof",
|
|
6595
|
+
"Fetch and cryptographically verify the token-only signed proof referenced by a qualified potential_savings estimate. Successful results include signature_verified=true. Public-skill proofs are anonymous reads; organization-skill proofs require an active query-capable API key from the same organization, but not necessarily the key used for the original query. Proof payloads contain no organization identity, task identity, price, credit, subscription, or payment data.",
|
|
6596
|
+
"/api/v1/value-proofs/{id}",
|
|
6597
|
+
getValueProofSchema,
|
|
6598
|
+
"GET"
|
|
6599
|
+
),
|
|
6110
6600
|
tool(
|
|
6111
6601
|
"submit_remembrance",
|
|
6112
6602
|
"Submit a full remembrance payload with detailed reusable evidence, including high-value self-corrections, user-caught mistakes, CI/deploy failures, and release/versioning misses as type failure_report. Do not include secrets or raw private payloads.",
|
|
@@ -6205,10 +6695,12 @@ function resolveApiKey() {
|
|
|
6205
6695
|
return fromFile ? String(fromFile) : "";
|
|
6206
6696
|
}
|
|
6207
6697
|
var apiBase = (process.env.REMEMBRANCE_API_URL || readRemembranceConfig().apiUrl || "https://remembrance.dev").replace(/\/$/, "");
|
|
6208
|
-
var SERVER_VERSION = true ? "0.1.
|
|
6698
|
+
var SERVER_VERSION = true ? "0.1.27" : "0.0.0-dev";
|
|
6209
6699
|
var tools = toolDefinitions;
|
|
6210
6700
|
var inputBuffer = Buffer.alloc(0);
|
|
6211
6701
|
var clientFraming = "ndjson";
|
|
6702
|
+
var cachedEconomicsSession = null;
|
|
6703
|
+
var cachedValueProofKeys = null;
|
|
6212
6704
|
process.stdin.on("data", (chunk) => {
|
|
6213
6705
|
inputBuffer = Buffer.concat([inputBuffer, chunk]);
|
|
6214
6706
|
processMessages().catch((error) => {
|
|
@@ -6294,7 +6786,6 @@ async function handleRequest(request) {
|
|
|
6294
6786
|
}
|
|
6295
6787
|
writeResponse(response.id, response.result, response.error);
|
|
6296
6788
|
}
|
|
6297
|
-
var SERVER_INSTRUCTIONS = "Remembrance is shared operational memory for agents. BEFORE non-trivial service/API/tool/library/deployment work, call query_skills to reuse proven skills and resources instead of rediscovering them. AFTER you use a skill or resource, close the loop so the next agent inherits what you learned: call submit_feedback (useful true/false + a one-line lesson \u2014 it returns a ready submit_remembrance payload), then submit_remembrance if the lesson is reusable, or propose_skill_idea only if nothing fit and you built a new workflow. If you catch your own mistake, the user catches one, CI/deploy fails, or you fix a release/versioning miss, submit a failure_report remembrance even if no skill was used; raw MCP clients have no plugin Stop hook to remind you later. Attach evidence (reproduction detail, artifact hashes, or an attestation) \u2014 evidence-less public reports wait in unverified intake until corroborated. Redact secrets, private URLs, credentials, and proprietary content; submit summaries and hashes, not raw traces.";
|
|
6298
6789
|
async function dispatchJsonRpcRequest(request) {
|
|
6299
6790
|
if (request.method === "initialize") {
|
|
6300
6791
|
return {
|
|
@@ -6306,7 +6797,7 @@ async function dispatchJsonRpcRequest(request) {
|
|
|
6306
6797
|
name: "@remembrance-ai/mcp-server",
|
|
6307
6798
|
version: SERVER_VERSION
|
|
6308
6799
|
},
|
|
6309
|
-
instructions:
|
|
6800
|
+
instructions: REMEMBRANCE_MCP_SERVER_INSTRUCTIONS
|
|
6310
6801
|
}
|
|
6311
6802
|
};
|
|
6312
6803
|
}
|
|
@@ -6596,7 +7087,14 @@ async function readIdentity(path = identityPath()) {
|
|
|
6596
7087
|
return JSON.parse(await readFile(path, "utf8"));
|
|
6597
7088
|
}
|
|
6598
7089
|
async function callRemembrance(definition, rawArguments) {
|
|
6599
|
-
const
|
|
7090
|
+
const parsed = definition.schema.parse(rawArguments ?? {});
|
|
7091
|
+
const payload = definition.name === "query_skills" ? {
|
|
7092
|
+
...parsed,
|
|
7093
|
+
client_context: {
|
|
7094
|
+
...parsed.client_context ?? {},
|
|
7095
|
+
surface: "mcp"
|
|
7096
|
+
}
|
|
7097
|
+
} : parsed;
|
|
6600
7098
|
const headers = {
|
|
6601
7099
|
"content-type": "application/json"
|
|
6602
7100
|
};
|
|
@@ -6604,6 +7102,14 @@ async function callRemembrance(definition, rawArguments) {
|
|
|
6604
7102
|
if (apiKey) {
|
|
6605
7103
|
headers["x-remembrance-api-key"] = apiKey;
|
|
6606
7104
|
}
|
|
7105
|
+
if (definition.name !== "bootstrap_agent_identity") {
|
|
7106
|
+
const economicsSession = await ensureEconomicsSessionToken().catch(
|
|
7107
|
+
() => null
|
|
7108
|
+
);
|
|
7109
|
+
if (economicsSession) {
|
|
7110
|
+
headers["x-remembrance-economics-session"] = economicsSession;
|
|
7111
|
+
}
|
|
7112
|
+
}
|
|
6607
7113
|
const endpoint = endpointFor(definition, payload);
|
|
6608
7114
|
const controller = new AbortController();
|
|
6609
7115
|
const timeout = setTimeout(() => controller.abort(), apiTimeoutMs());
|
|
@@ -6627,15 +7133,54 @@ async function callRemembrance(definition, rawArguments) {
|
|
|
6627
7133
|
const body = await response.json().catch(async () => ({
|
|
6628
7134
|
text: await response.text().catch(() => "")
|
|
6629
7135
|
}));
|
|
7136
|
+
const verifiedBody = definition.name === "get_value_proof" && response.ok ? await verifySignedValueProofWithKeyRefresh(body, fetchValueProofKeySet) : body;
|
|
6630
7137
|
return {
|
|
6631
7138
|
ok: response.ok,
|
|
6632
7139
|
status: response.status,
|
|
6633
7140
|
idempotency_status: response.headers.get("idempotency-status"),
|
|
6634
7141
|
rate_limit_remaining: response.headers.get("x-ratelimit-remaining"),
|
|
6635
7142
|
etag: response.headers.get("etag"),
|
|
6636
|
-
body
|
|
7143
|
+
body: verifiedBody
|
|
6637
7144
|
};
|
|
6638
7145
|
}
|
|
7146
|
+
async function fetchValueProofKeySet(forceRefresh) {
|
|
7147
|
+
const now = Date.now();
|
|
7148
|
+
if (!forceRefresh && cachedValueProofKeys && cachedValueProofKeys.expiresAt > now) {
|
|
7149
|
+
return cachedValueProofKeys.value;
|
|
7150
|
+
}
|
|
7151
|
+
const controller = new AbortController();
|
|
7152
|
+
const timeout = setTimeout(() => controller.abort(), apiTimeoutMs());
|
|
7153
|
+
try {
|
|
7154
|
+
const response = await fetch(
|
|
7155
|
+
`${apiBase}/.well-known/remembrance-value-proof-keys.json`,
|
|
7156
|
+
{
|
|
7157
|
+
headers: { accept: "application/json" },
|
|
7158
|
+
signal: controller.signal
|
|
7159
|
+
}
|
|
7160
|
+
);
|
|
7161
|
+
if (!response.ok) {
|
|
7162
|
+
throw new Error(
|
|
7163
|
+
`Value proof verification keys are unavailable (${response.status}).`
|
|
7164
|
+
);
|
|
7165
|
+
}
|
|
7166
|
+
const value = await response.json();
|
|
7167
|
+
cachedValueProofKeys = {
|
|
7168
|
+
value,
|
|
7169
|
+
expiresAt: now + valueProofKeyCacheTtlMs(response.headers)
|
|
7170
|
+
};
|
|
7171
|
+
return value;
|
|
7172
|
+
} finally {
|
|
7173
|
+
clearTimeout(timeout);
|
|
7174
|
+
}
|
|
7175
|
+
}
|
|
7176
|
+
function valueProofKeyCacheTtlMs(headers) {
|
|
7177
|
+
const maxAge = headers.get("cache-control")?.match(/(?:^|,)\s*max-age=(\d+)/i)?.[1];
|
|
7178
|
+
const seconds = Number(maxAge);
|
|
7179
|
+
return Number.isFinite(seconds) && seconds > 0 ? Math.min(300, Math.trunc(seconds)) * 1e3 : 3e5;
|
|
7180
|
+
}
|
|
7181
|
+
function resetValueProofKeyCacheForTests() {
|
|
7182
|
+
cachedValueProofKeys = null;
|
|
7183
|
+
}
|
|
6639
7184
|
function apiTimeoutMs() {
|
|
6640
7185
|
const parsed = Number.parseInt(
|
|
6641
7186
|
process.env.REMEMBRANCE_API_TIMEOUT_MS ?? "",
|
|
@@ -6647,10 +7192,67 @@ function endpointFor(definition, payload) {
|
|
|
6647
7192
|
if (!definition.endpoint) {
|
|
6648
7193
|
throw new Error(`Tool ${definition.name} has no HTTP endpoint.`);
|
|
6649
7194
|
}
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
)
|
|
7195
|
+
const endpoint = definition.endpoint.replaceAll("{slug}", encodeURIComponent(String(payload.slug ?? ""))).replaceAll("{id}", encodeURIComponent(String(payload.id ?? "")));
|
|
7196
|
+
if (definition.method !== "GET") return endpoint;
|
|
7197
|
+
const params = new URLSearchParams();
|
|
7198
|
+
for (const key of ["query_id", "result_id"]) {
|
|
7199
|
+
if (typeof payload[key] === "string" && payload[key]) {
|
|
7200
|
+
params.set(key, payload[key]);
|
|
7201
|
+
}
|
|
7202
|
+
}
|
|
7203
|
+
const query = params.toString();
|
|
7204
|
+
return query ? `${endpoint}?${query}` : endpoint;
|
|
7205
|
+
}
|
|
7206
|
+
async function ensureEconomicsSessionToken() {
|
|
7207
|
+
const identity = await readIdentity();
|
|
7208
|
+
if (!identity) return null;
|
|
7209
|
+
const identityKey = `${identity.provider}:${identity.key_id}`;
|
|
7210
|
+
if (cachedEconomicsSession && cachedEconomicsSession.identityKey === identityKey && cachedEconomicsSession.expiresAt > Date.now() + 6e4) {
|
|
7211
|
+
return cachedEconomicsSession.token;
|
|
7212
|
+
}
|
|
7213
|
+
const challengeResponse = await directEconomicsSessionRequest({
|
|
7214
|
+
action: "challenge",
|
|
7215
|
+
provider: identity.provider,
|
|
7216
|
+
key_id: identity.key_id
|
|
7217
|
+
});
|
|
7218
|
+
const challenge = challengeResponse;
|
|
7219
|
+
if (!challenge.challenge_id || !challenge.signing_payload) return null;
|
|
7220
|
+
const signature = signPayload(
|
|
7221
|
+
null,
|
|
7222
|
+
Buffer.from(challenge.signing_payload),
|
|
7223
|
+
createPrivateKey(identity.private_key)
|
|
7224
|
+
).toString("base64url");
|
|
7225
|
+
const exchangeResponse = await directEconomicsSessionRequest({
|
|
7226
|
+
action: "exchange",
|
|
7227
|
+
provider: identity.provider,
|
|
7228
|
+
key_id: identity.key_id,
|
|
7229
|
+
challenge_id: challenge.challenge_id,
|
|
7230
|
+
signature
|
|
7231
|
+
});
|
|
7232
|
+
const exchange = exchangeResponse;
|
|
7233
|
+
if (!exchange.session_token || !exchange.expires_at) return null;
|
|
7234
|
+
cachedEconomicsSession = {
|
|
7235
|
+
token: exchange.session_token,
|
|
7236
|
+
expiresAt: new Date(exchange.expires_at).getTime(),
|
|
7237
|
+
identityKey
|
|
7238
|
+
};
|
|
7239
|
+
return cachedEconomicsSession.token;
|
|
7240
|
+
}
|
|
7241
|
+
async function directEconomicsSessionRequest(payload) {
|
|
7242
|
+
const controller = new AbortController();
|
|
7243
|
+
const timeout = setTimeout(() => controller.abort(), apiTimeoutMs());
|
|
7244
|
+
try {
|
|
7245
|
+
const response = await fetch(`${apiBase}/api/v1/agent/economics/session`, {
|
|
7246
|
+
method: "POST",
|
|
7247
|
+
headers: { "content-type": "application/json" },
|
|
7248
|
+
body: JSON.stringify(payload),
|
|
7249
|
+
signal: controller.signal
|
|
7250
|
+
});
|
|
7251
|
+
if (!response.ok) return null;
|
|
7252
|
+
return response.json();
|
|
7253
|
+
} finally {
|
|
7254
|
+
clearTimeout(timeout);
|
|
7255
|
+
}
|
|
6654
7256
|
}
|
|
6655
7257
|
function mustFindTool(name) {
|
|
6656
7258
|
const tool2 = tools.find((item) => item.name === name);
|
|
@@ -6702,5 +7304,6 @@ export {
|
|
|
6702
7304
|
callTool,
|
|
6703
7305
|
dispatchJsonRpcRequest,
|
|
6704
7306
|
formatJsonRpcResponse,
|
|
6705
|
-
readJsonRpcMessages
|
|
7307
|
+
readJsonRpcMessages,
|
|
7308
|
+
resetValueProofKeyCacheForTests
|
|
6706
7309
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remembrance-ai/mcp-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"mcpName": "io.github.dreamarkinc/remembrance",
|
|
5
5
|
"description": "MCP server for discovering Remembrance skills/resources and submitting agent feedback with optional TOFU attestations.",
|
|
6
6
|
"license": "Apache-2.0",
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/dreamarkinc/remembrance-skills",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.27",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@remembrance-ai/mcp-server",
|
|
14
|
-
"version": "0.1.
|
|
14
|
+
"version": "0.1.27",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|