@plurnk/plurnk-contracts 9.0.0 → 10.0.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.
Files changed (81) hide show
  1. package/.env.defaults +1 -19
  2. package/README.md +5 -6
  3. package/SPEC.md +93 -44
  4. package/dist/schema/DaemonNotificationEnvelope.json +77 -30
  5. package/dist/schema/FunctionalityCandidate.json +4 -0
  6. package/dist/schema/FunctionalityDiscoverQuery.json +12 -0
  7. package/dist/schema/FunctionalityDiscoverResult.json +10 -0
  8. package/dist/schema/FunctionalityListQuery.json +33 -0
  9. package/dist/schema/FunctionalityListResult.json +16 -1
  10. package/dist/schema/ModelCatalogPage.json +9 -0
  11. package/dist/schema/PlurnkStatement.json +18 -2
  12. package/dist/schema/ProviderAccounting.json +3 -3
  13. package/dist/schema/ProviderCost.json +1 -1
  14. package/dist/schema/ProviderRequestAccounting.json +3 -3
  15. package/dist/schema/ProviderUsage.json +1 -1
  16. package/dist/src/ActorIdentity.d.ts +26 -0
  17. package/dist/src/ActorIdentity.d.ts.map +1 -0
  18. package/dist/src/ActorIdentity.js +179 -0
  19. package/dist/src/ActorIdentity.js.map +1 -0
  20. package/dist/src/Application.d.ts +38 -126
  21. package/dist/src/Application.d.ts.map +1 -1
  22. package/dist/src/Application.js +47 -220
  23. package/dist/src/Application.js.map +1 -1
  24. package/dist/src/ApplicationNotifications.d.ts +19 -6
  25. package/dist/src/ApplicationNotifications.d.ts.map +1 -1
  26. package/dist/src/ApplicationNotifications.js +6 -3
  27. package/dist/src/ApplicationNotifications.js.map +1 -1
  28. package/dist/src/ApplicationPort.d.ts +27 -6
  29. package/dist/src/ApplicationPort.d.ts.map +1 -1
  30. package/dist/src/ApplicationPort.js +1 -1
  31. package/dist/src/ApplicationPort.js.map +1 -1
  32. package/dist/src/ApplicationStream.d.ts +2 -2
  33. package/dist/src/ApplicationStream.d.ts.map +1 -1
  34. package/dist/src/ApplicationStream.js.map +1 -1
  35. package/dist/src/CollectionCommand.d.ts +33 -0
  36. package/dist/src/CollectionCommand.d.ts.map +1 -0
  37. package/dist/src/CollectionCommand.js +277 -0
  38. package/dist/src/CollectionCommand.js.map +1 -0
  39. package/dist/src/Functionality.d.ts +7 -2
  40. package/dist/src/Functionality.d.ts.map +1 -1
  41. package/dist/src/Functionality.js.map +1 -1
  42. package/dist/src/HttpOrigin.d.ts +79 -10
  43. package/dist/src/HttpOrigin.d.ts.map +1 -1
  44. package/dist/src/HttpOrigin.js +286 -44
  45. package/dist/src/HttpOrigin.js.map +1 -1
  46. package/dist/src/HttpPort.d.ts +35 -0
  47. package/dist/src/HttpPort.d.ts.map +1 -0
  48. package/dist/src/HttpPort.js +106 -0
  49. package/dist/src/HttpPort.js.map +1 -0
  50. package/dist/src/InteractiveCommands.d.ts +96 -0
  51. package/dist/src/InteractiveCommands.d.ts.map +1 -0
  52. package/dist/src/InteractiveCommands.js +409 -0
  53. package/dist/src/InteractiveCommands.js.map +1 -0
  54. package/dist/src/McpWireTool.d.ts +27 -0
  55. package/dist/src/McpWireTool.d.ts.map +1 -0
  56. package/dist/src/McpWireTool.js +30 -0
  57. package/dist/src/McpWireTool.js.map +1 -0
  58. package/dist/src/OAuthClient.d.ts +64 -0
  59. package/dist/src/OAuthClient.d.ts.map +1 -0
  60. package/dist/src/OAuthClient.js +226 -0
  61. package/dist/src/OAuthClient.js.map +1 -0
  62. package/dist/src/ScheduleCommand.d.ts +60 -0
  63. package/dist/src/ScheduleCommand.d.ts.map +1 -0
  64. package/dist/src/ScheduleCommand.js +677 -0
  65. package/dist/src/ScheduleCommand.js.map +1 -0
  66. package/dist/src/SessionProjection.d.ts +91 -0
  67. package/dist/src/SessionProjection.d.ts.map +1 -0
  68. package/dist/src/SessionProjection.js +223 -0
  69. package/dist/src/SessionProjection.js.map +1 -0
  70. package/dist/src/Validator.d.ts +2 -1
  71. package/dist/src/Validator.d.ts.map +1 -1
  72. package/dist/src/Validator.js +19 -1
  73. package/dist/src/Validator.js.map +1 -1
  74. package/dist/src/index.d.ts +10 -3
  75. package/dist/src/index.d.ts.map +1 -1
  76. package/dist/src/index.js +7 -1
  77. package/dist/src/index.js.map +1 -1
  78. package/dist/src/types.generated.d.ts +85 -21
  79. package/dist/src/types.generated.d.ts.map +1 -1
  80. package/dist/src/types.generated.js.map +1 -1
  81. package/package.json +3 -2
@@ -28,6 +28,15 @@
28
28
  "type": "integer",
29
29
  "minimum": 1,
30
30
  "maximum": 9007199254740991
31
+ },
32
+ "providers": {
33
+ "description": "Sorted unique provider ids available in this availability-scoped catalog.",
34
+ "type": "array",
35
+ "uniqueItems": true,
36
+ "items": {
37
+ "type": "string",
38
+ "minLength": 1
39
+ }
31
40
  }
32
41
  },
33
42
  "$defs": {
@@ -356,6 +356,12 @@
356
356
  "body": {
357
357
  "$ref": "#/$defs/SendBodyOrNull"
358
358
  },
359
+ "actor": {
360
+ "type": [
361
+ "string",
362
+ "null"
363
+ ]
364
+ },
359
365
  "position": {
360
366
  "$ref": "#/$defs/PositionRef"
361
367
  }
@@ -468,6 +474,17 @@
468
474
  "null"
469
475
  ]
470
476
  },
477
+ "env": {
478
+ "description": "Optional per-invocation environment variables (`{ [name: string]: string }`).",
479
+ "type": "object",
480
+ "propertyNames": {
481
+ "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
482
+ },
483
+ "additionalProperties": {
484
+ "type": "string"
485
+ },
486
+ "tsType": "Readonly<Record<string, string>>"
487
+ },
471
488
  "lineMarker": {
472
489
  "$ref": "#/$defs/LineMarkerOrNull"
473
490
  },
@@ -554,8 +571,7 @@
554
571
  "description": "The selection matcher lifted from the `pattern` option ({§parse-recovery}); null when omitted."
555
572
  },
556
573
  "body": {
557
- "type": ["string", "null"],
558
- "description": "A `log:///` `kill` carries its optional distillation, kept as the model's own `note` row ({§log-kill-scope}). Other `kill` statements take no body; their matcher rides on the `pattern` option ({§parse-recovery})."
574
+ "type": "null"
559
575
  },
560
576
  "position": {
561
577
  "$ref": "#/$defs/PositionRef"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.xyz/ProviderAccounting.json",
3
+ "$id": "https://schemas.plurnk.xyz/v0/ProviderAccounting.json",
4
4
  "title": "ProviderAccounting",
5
5
  "description": "Ordered physical provider-request evidence and its deterministic aggregate projection.",
6
6
  "type": "object",
@@ -9,11 +9,11 @@
9
9
  "properties": {
10
10
  "requests": {
11
11
  "type": "array",
12
- "items": { "$ref": "https://schemas.plurnk.xyz/ProviderRequestAccounting.json" }
12
+ "items": { "$ref": "https://schemas.plurnk.xyz/v0/ProviderRequestAccounting.json" }
13
13
  },
14
14
  "usage": {
15
15
  "oneOf": [
16
- { "$ref": "https://schemas.plurnk.xyz/ProviderUsage.json" },
16
+ { "$ref": "https://schemas.plurnk.xyz/v0/ProviderUsage.json" },
17
17
  { "type": "null" }
18
18
  ]
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.xyz/ProviderCost.json",
3
+ "$id": "https://schemas.plurnk.xyz/v0/ProviderCost.json",
4
4
  "title": "ProviderCost",
5
5
  "description": "Normalized monetary evidence for one physical provider request. Unknown is never represented as zero.",
6
6
  "oneOf": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.xyz/ProviderRequestAccounting.json",
3
+ "$id": "https://schemas.plurnk.xyz/v0/ProviderRequestAccounting.json",
4
4
  "title": "ProviderRequestAccounting",
5
5
  "description": "The normalized accounting disposition of one physical provider request.",
6
6
  "type": "object",
@@ -11,7 +11,7 @@
11
11
  "model": { "type": "string", "minLength": 1 },
12
12
  "outcome": { "enum": ["response", "error"] },
13
13
  "status": { "type": "integer", "minimum": 100, "maximum": 599 },
14
- "usage": { "$ref": "https://schemas.plurnk.xyz/ProviderUsage.json" },
15
- "cost": { "$ref": "https://schemas.plurnk.xyz/ProviderCost.json" }
14
+ "usage": { "$ref": "https://schemas.plurnk.xyz/v0/ProviderUsage.json" },
15
+ "cost": { "$ref": "https://schemas.plurnk.xyz/v0/ProviderCost.json" }
16
16
  }
17
17
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://schemas.plurnk.xyz/ProviderUsage.json",
3
+ "$id": "https://schemas.plurnk.xyz/v0/ProviderUsage.json",
4
4
  "title": "ProviderUsage",
5
5
  "description": "Token quantities. Physical-request instances enforce their partition identities. ProviderAccounting distinguishes complete usage from knownUsage subtotals. Omitted fields are unknown; explicit zero is observed or exactly derived.",
6
6
  "type": "object",
@@ -0,0 +1,26 @@
1
+ export type ExteriorActorScheme = "acp" | "mcp";
2
+ export interface ExteriorActor {
3
+ readonly name: string;
4
+ readonly scheme: ExteriorActorScheme;
5
+ readonly uri: string;
6
+ }
7
+ export declare const isDefaultExteriorActor: (name: string | null | undefined) => boolean;
8
+ /**
9
+ * Parse and normalize an exterior actor identifier (bare name like `"hazool17"` or
10
+ * authority-only exterior URI like `"acp://hazool17"` / `"mcp://bridge"`).
11
+ * Rejects internal schemes (`session://`, `message://`, `log://`, etc.), `_plurnk`,
12
+ * path/query/fragment/userinfo/port components, whitespace, and malformed encodings.
13
+ */
14
+ export declare const parseExteriorActor: (raw: string, defaultScheme?: ExteriorActorScheme) => ExteriorActor | null;
15
+ /**
16
+ * Compare a caller-requested actor (bare name or exterior URI) against an
17
+ * authenticated credential subject (`admission.subject`).
18
+ */
19
+ export declare const actorsMatch: (requested: string, authenticatedSubject: string) => boolean;
20
+ /**
21
+ * Extract the non-default causal actor name from a Plurnk message source or address URI
22
+ * (`acp://<actor>[/...]`, `mcp://<actor>[/...]`, `session://<worker>[/...]`, or `message://<session>/<actor>_<seq>`).
23
+ * Returns `undefined` for unnamed default exterior actors (`operator`, `anonymous`, `client`, `owner`) or `_plurnk`.
24
+ */
25
+ export declare const extractActor: (sourceOrAddress: string | null | undefined) => string | undefined;
26
+ //# sourceMappingURL=ActorIdentity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorIdentity.d.ts","sourceRoot":"","sources":["../../src/ActorIdentity.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,KAAK,CAAC;AAEhD,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACxB;AA8BD,eAAO,MAAM,sBAAsB,SAAU,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,OAGxE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,QACtB,MAAM,kBACI,mBAAmB,KACnC,aAAa,GAAG,IA2ClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,cAAe,MAAM,wBAAwB,MAAM,KAAG,OAS7E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,oBAAqB,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAAM,GAAG,SAsElF,CAAC"}
@@ -0,0 +1,179 @@
1
+ // {§contract-representations} {§client-session-status} Runtime-neutral exterior actor parsing, normalization, and attribution extraction.
2
+ const UNNAMED_EXTERIOR_ACTORS = new Set([
3
+ "",
4
+ "operator",
5
+ "anonymous",
6
+ "client",
7
+ "owner",
8
+ ]);
9
+ const RESERVED_ACTOR_NAMES = new Set([
10
+ "_plurnk",
11
+ ".",
12
+ "..",
13
+ ]);
14
+ const EXTERIOR_ACTOR_SCHEMES = new Set(["acp", "mcp"]);
15
+ // Bare exterior actor names forbid whitespace, ASCII control chars, and URI structural delimiters.
16
+ const isValidActorName = (value) => {
17
+ if (value.length === 0 || value.length > 256)
18
+ return false;
19
+ if (value === "_plurnk" || value === "." || value === "..")
20
+ return false;
21
+ if (!value.isWellFormed())
22
+ return false;
23
+ for (let i = 0; i < value.length; i += 1) {
24
+ const code = value.charCodeAt(i);
25
+ if (code <= 0x20 || code === 0x7f)
26
+ return false;
27
+ }
28
+ return !/[/?#\\]/u.test(value);
29
+ };
30
+ export const isDefaultExteriorActor = (name) => {
31
+ if (typeof name !== "string")
32
+ return true;
33
+ return UNNAMED_EXTERIOR_ACTORS.has(name.trim());
34
+ };
35
+ /**
36
+ * Parse and normalize an exterior actor identifier (bare name like `"hazool17"` or
37
+ * authority-only exterior URI like `"acp://hazool17"` / `"mcp://bridge"`).
38
+ * Rejects internal schemes (`session://`, `message://`, `log://`, etc.), `_plurnk`,
39
+ * path/query/fragment/userinfo/port components, whitespace, and malformed encodings.
40
+ */
41
+ export const parseExteriorActor = (raw, defaultScheme = "acp") => {
42
+ const trimmed = raw.trim();
43
+ if (trimmed.length === 0 || RESERVED_ACTOR_NAMES.has(trimmed))
44
+ return null;
45
+ const schemeMatch = /^([a-z][a-z0-9+.-]*):\/\//iu.exec(trimmed);
46
+ if (schemeMatch !== null) {
47
+ const scheme = (schemeMatch[1] ?? "").toLowerCase();
48
+ if (!EXTERIOR_ACTOR_SCHEMES.has(scheme))
49
+ return null;
50
+ const rest = trimmed.slice(schemeMatch[0].length);
51
+ // Authority-only: reject pathname (except optional trailing slash), query, fragment, userinfo, or port.
52
+ const authority = rest.endsWith("/") ? rest.slice(0, -1) : rest;
53
+ if (authority.length === 0 ||
54
+ authority.includes("/") ||
55
+ authority.includes("?") ||
56
+ authority.includes("#") ||
57
+ authority.includes("@") ||
58
+ authority.includes(":")) {
59
+ return null;
60
+ }
61
+ let decoded;
62
+ try {
63
+ decoded = decodeURIComponent(authority);
64
+ }
65
+ catch {
66
+ return null;
67
+ }
68
+ if (!isValidActorName(decoded))
69
+ return null;
70
+ const typedScheme = scheme === "mcp" ? "mcp" : "acp";
71
+ return {
72
+ name: decoded,
73
+ scheme: typedScheme,
74
+ uri: `${typedScheme}://${encodeURIComponent(decoded)}`,
75
+ };
76
+ }
77
+ if (trimmed.includes("://"))
78
+ return null;
79
+ if (!isValidActorName(trimmed))
80
+ return null;
81
+ return {
82
+ name: trimmed,
83
+ scheme: defaultScheme,
84
+ uri: `${defaultScheme}://${encodeURIComponent(trimmed)}`,
85
+ };
86
+ };
87
+ /**
88
+ * Compare a caller-requested actor (bare name or exterior URI) against an
89
+ * authenticated credential subject (`admission.subject`).
90
+ */
91
+ export const actorsMatch = (requested, authenticatedSubject) => {
92
+ const reqTrimmed = requested.trim();
93
+ const subTrimmed = authenticatedSubject.trim();
94
+ if (reqTrimmed.length === 0 || subTrimmed.length === 0)
95
+ return false;
96
+ const reqParsed = parseExteriorActor(reqTrimmed);
97
+ const subParsed = parseExteriorActor(subTrimmed);
98
+ const reqName = reqParsed?.name ?? reqTrimmed;
99
+ const subName = subParsed?.name ?? subTrimmed;
100
+ return reqName === subName;
101
+ };
102
+ /**
103
+ * Extract the non-default causal actor name from a Plurnk message source or address URI
104
+ * (`acp://<actor>[/...]`, `mcp://<actor>[/...]`, `session://<worker>[/...]`, or `message://<session>/<actor>_<seq>`).
105
+ * Returns `undefined` for unnamed default exterior actors (`operator`, `anonymous`, `client`, `owner`) or `_plurnk`.
106
+ */
107
+ export const extractActor = (sourceOrAddress) => {
108
+ if (typeof sourceOrAddress !== "string" || sourceOrAddress.length === 0)
109
+ return undefined;
110
+ const acpMatch = /^acp:\/\/([^/?#]+)/u.exec(sourceOrAddress);
111
+ if (acpMatch !== null) {
112
+ try {
113
+ const principal = decodeURIComponent(acpMatch[1] ?? "");
114
+ if (principal.length > 0 && !UNNAMED_EXTERIOR_ACTORS.has(principal) && principal !== "_plurnk") {
115
+ return principal;
116
+ }
117
+ }
118
+ catch {
119
+ // fall through
120
+ }
121
+ return undefined;
122
+ }
123
+ const mcpMatch = /^mcp:\/\/([^/?#]+)/u.exec(sourceOrAddress);
124
+ if (mcpMatch !== null) {
125
+ try {
126
+ const principal = decodeURIComponent(mcpMatch[1] ?? "");
127
+ if (principal.length > 0 && !UNNAMED_EXTERIOR_ACTORS.has(principal) && principal !== "_plurnk") {
128
+ return principal;
129
+ }
130
+ }
131
+ catch {
132
+ // fall through
133
+ }
134
+ return undefined;
135
+ }
136
+ const sessionMatch = /^session:\/\/([^/?#]+)/u.exec(sourceOrAddress);
137
+ if (sessionMatch !== null) {
138
+ try {
139
+ const worker = decodeURIComponent(sessionMatch[1] ?? "");
140
+ if (worker.length > 0 && worker !== "_plurnk")
141
+ return worker;
142
+ }
143
+ catch {
144
+ // fall through
145
+ }
146
+ return undefined;
147
+ }
148
+ const messageMatch = /^message:\/\/[^/?#]+\/([^/?#]+)_([0-9a-zA-Z]{2,5})$/u.exec(sourceOrAddress);
149
+ if (messageMatch !== null) {
150
+ try {
151
+ const principal = decodeURIComponent(messageMatch[1] ?? "");
152
+ if (principal.length > 0 && !UNNAMED_EXTERIOR_ACTORS.has(principal) && principal !== "_plurnk") {
153
+ return principal;
154
+ }
155
+ }
156
+ catch {
157
+ // fall through
158
+ }
159
+ return undefined;
160
+ }
161
+ const schedulePathMatch = /^schedule:\/\/\/([^?#]+)$/u.exec(sourceOrAddress.split(/[?#]/u, 1)[0] ?? "");
162
+ if (schedulePathMatch !== null) {
163
+ const segments = (schedulePathMatch[1] ?? "").split("/").filter((s) => s.length > 0);
164
+ const rawAlias = segments[0] === "rules" ? segments[1] : segments[0];
165
+ if (rawAlias !== undefined && rawAlias.length > 0) {
166
+ try {
167
+ const alias = decodeURIComponent(rawAlias);
168
+ if (alias.length > 0 && !UNNAMED_EXTERIOR_ACTORS.has(alias) && alias !== "_plurnk") {
169
+ return alias;
170
+ }
171
+ }
172
+ catch {
173
+ // fall through
174
+ }
175
+ }
176
+ }
177
+ return undefined;
178
+ };
179
+ //# sourceMappingURL=ActorIdentity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorIdentity.js","sourceRoot":"","sources":["../../src/ActorIdentity.ts"],"names":[],"mappings":"AAAA,0IAA0I;AAU1I,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AAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACrE,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,IAAI,CAAC;gBACD,MAAM,KAAK,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;gBAC3C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACjF,OAAO,KAAK,CAAC;gBACjB,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACL,eAAe;YACnB,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC","sourcesContent":["// {§contract-representations} {§client-session-status} Runtime-neutral exterior actor parsing, normalization, and attribution extraction.\n\nexport type ExteriorActorScheme = \"acp\" | \"mcp\";\n\nexport interface ExteriorActor {\n readonly name: string;\n readonly scheme: ExteriorActorScheme;\n readonly uri: string;\n}\n\nconst UNNAMED_EXTERIOR_ACTORS: ReadonlySet<string> = new Set([\n \"\",\n \"operator\",\n \"anonymous\",\n \"client\",\n \"owner\",\n]);\n\nconst RESERVED_ACTOR_NAMES: ReadonlySet<string> = new Set([\n \"_plurnk\",\n \".\",\n \"..\",\n]);\n\nconst EXTERIOR_ACTOR_SCHEMES: ReadonlySet<string> = new Set([\"acp\", \"mcp\"]);\n\n// Bare exterior actor names forbid whitespace, ASCII control chars, and URI structural delimiters.\nconst isValidActorName = (value: string): boolean => {\n if (value.length === 0 || value.length > 256) return false;\n if (value === \"_plurnk\" || value === \".\" || value === \"..\") return false;\n if (!value.isWellFormed()) return false;\n for (let i = 0; i < value.length; i += 1) {\n const code = value.charCodeAt(i);\n if (code <= 0x20 || code === 0x7f) return false;\n }\n return !/[/?#\\\\]/u.test(value);\n};\n\nexport const isDefaultExteriorActor = (name: string | null | undefined): boolean => {\n if (typeof name !== \"string\") return true;\n return UNNAMED_EXTERIOR_ACTORS.has(name.trim());\n};\n\n/**\n * Parse and normalize an exterior actor identifier (bare name like `\"hazool17\"` or\n * authority-only exterior URI like `\"acp://hazool17\"` / `\"mcp://bridge\"`).\n * Rejects internal schemes (`session://`, `message://`, `log://`, etc.), `_plurnk`,\n * path/query/fragment/userinfo/port components, whitespace, and malformed encodings.\n */\nexport const parseExteriorActor = (\n raw: string,\n defaultScheme: ExteriorActorScheme = \"acp\",\n): ExteriorActor | null => {\n const trimmed = raw.trim();\n if (trimmed.length === 0 || RESERVED_ACTOR_NAMES.has(trimmed)) return null;\n\n const schemeMatch = /^([a-z][a-z0-9+.-]*):\\/\\//iu.exec(trimmed);\n if (schemeMatch !== null) {\n const scheme = (schemeMatch[1] ?? \"\").toLowerCase();\n if (!EXTERIOR_ACTOR_SCHEMES.has(scheme)) return null;\n const rest = trimmed.slice(schemeMatch[0].length);\n // Authority-only: reject pathname (except optional trailing slash), query, fragment, userinfo, or port.\n const authority = rest.endsWith(\"/\") ? rest.slice(0, -1) : rest;\n if (\n authority.length === 0 ||\n authority.includes(\"/\") ||\n authority.includes(\"?\") ||\n authority.includes(\"#\") ||\n authority.includes(\"@\") ||\n authority.includes(\":\")\n ) {\n return null;\n }\n let decoded: string;\n try {\n decoded = decodeURIComponent(authority);\n } catch {\n return null;\n }\n if (!isValidActorName(decoded)) return null;\n const typedScheme: ExteriorActorScheme = scheme === \"mcp\" ? \"mcp\" : \"acp\";\n return {\n name: decoded,\n scheme: typedScheme,\n uri: `${typedScheme}://${encodeURIComponent(decoded)}`,\n };\n }\n\n if (trimmed.includes(\"://\")) return null;\n if (!isValidActorName(trimmed)) return null;\n return {\n name: trimmed,\n scheme: defaultScheme,\n uri: `${defaultScheme}://${encodeURIComponent(trimmed)}`,\n };\n};\n\n/**\n * Compare a caller-requested actor (bare name or exterior URI) against an\n * authenticated credential subject (`admission.subject`).\n */\nexport const actorsMatch = (requested: string, authenticatedSubject: string): boolean => {\n const reqTrimmed = requested.trim();\n const subTrimmed = authenticatedSubject.trim();\n if (reqTrimmed.length === 0 || subTrimmed.length === 0) return false;\n const reqParsed = parseExteriorActor(reqTrimmed);\n const subParsed = parseExteriorActor(subTrimmed);\n const reqName = reqParsed?.name ?? reqTrimmed;\n const subName = subParsed?.name ?? subTrimmed;\n return reqName === subName;\n};\n\n/**\n * Extract the non-default causal actor name from a Plurnk message source or address URI\n * (`acp://<actor>[/...]`, `mcp://<actor>[/...]`, `session://<worker>[/...]`, or `message://<session>/<actor>_<seq>`).\n * Returns `undefined` for unnamed default exterior actors (`operator`, `anonymous`, `client`, `owner`) or `_plurnk`.\n */\nexport const extractActor = (sourceOrAddress: string | null | undefined): string | undefined => {\n if (typeof sourceOrAddress !== \"string\" || sourceOrAddress.length === 0) return undefined;\n\n const acpMatch = /^acp:\\/\\/([^/?#]+)/u.exec(sourceOrAddress);\n if (acpMatch !== null) {\n try {\n const principal = decodeURIComponent(acpMatch[1] ?? \"\");\n if (principal.length > 0 && !UNNAMED_EXTERIOR_ACTORS.has(principal) && principal !== \"_plurnk\") {\n return principal;\n }\n } catch {\n // fall through\n }\n return undefined;\n }\n\n const mcpMatch = /^mcp:\\/\\/([^/?#]+)/u.exec(sourceOrAddress);\n if (mcpMatch !== null) {\n try {\n const principal = decodeURIComponent(mcpMatch[1] ?? \"\");\n if (principal.length > 0 && !UNNAMED_EXTERIOR_ACTORS.has(principal) && principal !== \"_plurnk\") {\n return principal;\n }\n } catch {\n // fall through\n }\n return undefined;\n }\n\n const sessionMatch = /^session:\\/\\/([^/?#]+)/u.exec(sourceOrAddress);\n if (sessionMatch !== null) {\n try {\n const worker = decodeURIComponent(sessionMatch[1] ?? \"\");\n if (worker.length > 0 && worker !== \"_plurnk\") return worker;\n } catch {\n // fall through\n }\n return undefined;\n }\n\n const messageMatch = /^message:\\/\\/[^/?#]+\\/([^/?#]+)_([0-9a-zA-Z]{2,5})$/u.exec(sourceOrAddress);\n if (messageMatch !== null) {\n try {\n const principal = decodeURIComponent(messageMatch[1] ?? \"\");\n if (principal.length > 0 && !UNNAMED_EXTERIOR_ACTORS.has(principal) && principal !== \"_plurnk\") {\n return principal;\n }\n } catch {\n // fall through\n }\n return undefined;\n }\n\n const schedulePathMatch = /^schedule:\\/\\/\\/([^?#]+)$/u.exec(sourceOrAddress.split(/[?#]/u, 1)[0] ?? \"\");\n if (schedulePathMatch !== null) {\n const segments = (schedulePathMatch[1] ?? \"\").split(\"/\").filter((s) => s.length > 0);\n const rawAlias = segments[0] === \"rules\" ? segments[1] : segments[0];\n if (rawAlias !== undefined && rawAlias.length > 0) {\n try {\n const alias = decodeURIComponent(rawAlias);\n if (alias.length > 0 && !UNNAMED_EXTERIOR_ACTORS.has(alias) && alias !== \"_plurnk\") {\n return alias;\n }\n } catch {\n // fall through\n }\n }\n }\n\n return undefined;\n};\n"]}
@@ -43,14 +43,14 @@ export type ApplicationSessionKind = "root" | "fork" | "work";
43
43
  export interface ApplicationSessionProjection {
44
44
  readonly id: number;
45
45
  readonly name: string;
46
- readonly created_at: string;
46
+ readonly createdAt: string;
47
47
  readonly origin: ApplicationSessionOrigin;
48
48
  readonly owner: string;
49
49
  readonly parentSessionId: number | null;
50
50
  readonly kind: ApplicationSessionKind;
51
51
  readonly lifecycle: LoopLifecycle;
52
52
  /** {§machine-processes} When the session was archived, or null while it is unarchived. */
53
- readonly archived_at: string | null;
53
+ readonly archivedAt: string | null;
54
54
  /** {§machine-processes} Optional human-readable title set via `session/set_title`. */
55
55
  readonly title?: string | null;
56
56
  /** {§persona-discovery} Durable workspace persona bound to this session, or null when unset. */
@@ -103,13 +103,13 @@ export interface ApplicationSessionOverview {
103
103
  export interface ApplicationWorkspaceArchiving {
104
104
  readonly id: number;
105
105
  /** When the workspace was archived, or null while it is unarchived. */
106
- readonly archived_at: string | null;
106
+ readonly archivedAt: string | null;
107
107
  }
108
108
  /** {§machine-processes} A session's mark after an archive or unarchive. */
109
109
  export interface ApplicationSessionArchiving {
110
110
  readonly id: number;
111
111
  /** When the session was archived, or null while it is unarchived. */
112
- readonly archived_at: string | null;
112
+ readonly archivedAt: string | null;
113
113
  /** The sessions whose mark the call changed, in id order: the group it archived or unarchived, none when nothing changed. */
114
114
  readonly sessionIds: readonly number[];
115
115
  }
@@ -192,12 +192,12 @@ export interface ApplicationGauge {
192
192
  }
193
193
  export type LogEntryWire = LogAddressColumns & {
194
194
  id: number;
195
- session_id: number;
196
- session_name: string;
197
- loop_id: number;
198
- loop_seq: number;
199
- turn_id: number;
200
- turn_seq: number;
195
+ sessionId: number;
196
+ sessionName: string;
197
+ loopId: number;
198
+ loopSeq: number;
199
+ turnId: number;
200
+ turnSeq: number;
201
201
  sequence: number;
202
202
  at: string;
203
203
  origin: string;
@@ -206,19 +206,19 @@ export type LogEntryWire = LogAddressColumns & {
206
206
  signal: unknown;
207
207
  lineMarker: unknown;
208
208
  tx: unknown;
209
- mimetype_tx: string;
209
+ mimetypeTx: string;
210
210
  rx: unknown;
211
- mimetype_rx: string;
212
- status_rx: number;
211
+ mimetypeRx: string;
212
+ statusRx: number;
213
213
  weight: number;
214
214
  attrs: unknown;
215
215
  state: "proposed" | "resolved" | "failed" | "cancelled";
216
216
  reasoning?: string;
217
- reasoning_model_call_id?: number;
218
- reasoning_request_sequence?: number;
217
+ reasoningModelCallId?: number;
218
+ reasoningRequestSequence?: number;
219
219
  invocation?: string;
220
220
  answering?: string;
221
- replied_to_sources?: readonly string[];
221
+ repliedToSources?: readonly string[];
222
222
  };
223
223
  /** {§methods} A prompt's admission: its acknowledgement, the loop it landed on and how it landed. */
224
224
  export type ApplicationLoopAdmission = OperationResult & {
@@ -258,7 +258,7 @@ export interface ParsedFamilyCommand {
258
258
  readonly actionName: string;
259
259
  readonly params: Record<string, unknown>;
260
260
  }
261
- /** {§acp-action-binding} Parses a family command (`mcp`, `skills`, `personas`, `members`, `env`, `schedule`) into its action kind and parameters. */
261
+ /** {§acp-action-binding} {§client-family-commands} Parses a family command (`mcp`, `skills`, `personas`, `members`, `env`, `schedule`) into its action kind and parameters. */
262
262
  export declare const parseFamilyCommand: (family: string, args: readonly string[]) => ParsedFamilyCommand;
263
263
  /** {§acp-action-binding} Formats definition rows for `list` and multi-definition `members` mutations across CLI, ACP, and Web. */
264
264
  export declare const formatFamilyRows: (family: string, result: Readonly<Record<string, unknown>>) => string;
@@ -273,132 +273,44 @@ export type LearnCommandExpansion = {
273
273
  readonly ok: false;
274
274
  readonly error: string;
275
275
  };
276
- /** {§acp-action-binding} Expands `/learn [--scope project|plurnk] [instructions]` with folder-aware skill target resolution. */
276
+ /** {§acp-action-binding} {§client-composer-sigils} Expands `/learn [--scope project|plurnk] [instructions]` with folder-aware skill target resolution. */
277
277
  export declare const expandLearnCommand: (rawLine: string, options?: {
278
278
  readonly projectRoot?: string | null;
279
279
  }) => LearnCommandExpansion | null;
280
280
  export type ApplicationEventHandler = (workspaceId: number | null, method: DaemonNotificationEvent, params: unknown, notification: DaemonNotification) => void;
281
281
  /**
282
- * {§credential-authority} The kind of a credential: an access token is presented as a bearer; a
283
- * refresh token is exchanged for new credentials of its family and is never presented; a session
284
- * is a browser's standing at the authorization server ({§auth-oauth-clients}), never a bearer.
282
+ * {§credential-authority} The verified identity claims extracted from a presented OIDC / OAuth 2.1
283
+ * bearer token (`sub`, plus optional `email` and `expiresAt`).
285
284
  */
286
- export type CredentialKind = "access" | "refresh" | "session";
287
- /**
288
- * {§credential-authority} What an issued credential stands for. `family` names the grant it descends
289
- * from: revocation is by family, so an access token and the refresh token that renews it fall together.
290
- */
291
- export interface CredentialClaims {
292
- readonly kind: CredentialKind;
285
+ export interface VerifiedBearerClaims {
293
286
  readonly subject: string;
294
- readonly clientId: string;
295
- readonly scopes: readonly string[];
296
- readonly family: string;
297
- readonly expiresAt: number;
298
- }
299
- export interface IssuedCredential {
300
- readonly token: string;
301
- readonly expiresAt: number;
287
+ readonly email?: string;
288
+ readonly scopes?: readonly string[];
289
+ readonly expiresAt?: number;
302
290
  }
303
291
  /**
304
- * {§credential-authority} The issuing face of the authority, published by the module that issues:
305
- * the issuer origin where a request's caller obtains credentials, or, asked with no request in hand,
306
- * the configured issuer or the listener's own origin; answered from the moment it is published
307
- * ({§http-host}). Published, the daemon authenticates; absent, every mounted resource
308
- * admits anonymously.
292
+ * {§credential-authority} The resource-server credential verifier published at setup by an
293
+ * authentication module (such as `@plurnk/plurnk-auth` when `PLURNK_AUTH_ISSUER` is configured):
294
+ * resolves the daemon's public resource origin for RFC 9728 `resource_metadata` challenges
295
+ * ({§http-host}) and verifies presented bearer tokens. Published, the daemon authenticates every
296
+ * mounted resource; absent, every mounted resource admits without bearer tokens.
309
297
  */
310
298
  export interface CredentialFace {
311
299
  readonly issuer: (req?: RequestHeaders) => string;
300
+ readonly authorizationServer?: string;
301
+ readonly verify: (token: string) => Promise<VerifiedBearerClaims | null> | VerifiedBearerClaims | null;
312
302
  }
313
303
  /**
314
- * {§credential-authority} A live browser sign-in: the family every credential of that sign-in shares,
315
- * which is its handle and never a credential; whose it is; when it was established; when the last
316
- * of its session credentials expires; and the clients holding credentials in it. Never a token.
317
- */
318
- export interface CredentialSession {
319
- readonly family: string;
320
- readonly subject: string;
321
- readonly createdAt: number;
322
- readonly expiresAt: number;
323
- readonly clients: readonly string[];
324
- }
325
- /**
326
- * {§credential-authority} The confidential client a module of this daemon registers for itself at
327
- * setup: its id, the absolute pathnames under its own mounts it may be answered at, the scopes it may
328
- * ask for and, optionally, the pathname of a stylesheet it serves for the authority's documents shown
329
- * to its requests ({§auth-oauth-clients}). The issuer supplies the origin of each. What others may
330
- * know of it; never its secret.
331
- */
332
- export interface ModuleClient {
333
- readonly id: string;
334
- readonly redirectPaths: readonly string[];
335
- readonly scopes: readonly string[];
336
- readonly stylesheetPath?: string;
337
- }
338
- /**
339
- * {§credential-authority} {§auth-oauth-clients} A dynamically registered RFC 7591 public OAuth 2.1
340
- * client persisted alongside the authority's encrypted grants across daemon restarts.
341
- */
342
- export interface PublicOAuthClient {
343
- readonly id: string;
344
- readonly scopes: readonly string[];
345
- readonly redirectUris: readonly string[];
346
- readonly name: string | null;
347
- }
348
- /**
349
- * {§credential-authority} The daemon's one authority over the credentials presented to its listener:
350
- * opaque tokens it issued, live until they expire, are consumed, or their family or secret is revoked.
351
- * Every exterior adapter verifies through it; the client protocol is its issuing face.
304
+ * {§credential-authority} The daemon's one authority over bearer credentials presented to its
305
+ * listener. Every exterior adapter verifies through it; at most one authentication module publishes
306
+ * the active `CredentialFace` at `setup()`.
352
307
  */
353
308
  export interface CredentialAuthority {
354
- /**
355
- * The operator's client secret, `PLURNK_SECRET` when set, else the durable host secret beside
356
- * the database (or minted in memory when headless); null when the daemon authenticates nothing
357
- * (`PLURNK_AUTH=0`) and no credential exists.
358
- */
359
- readonly operatorSecret: string | null;
360
- issue(credential: Omit<CredentialClaims, "expiresAt"> & {
361
- readonly ttlMs: number;
362
- }): IssuedCredential;
363
- /** The claims of a live credential; null for one unknown, expired, consumed or revoked. */
364
- verify(token: string): CredentialClaims | null;
365
- /**
366
- * Retires a live refresh token in exchange for new credentials of its family. A token already
367
- * retired is a reuse: its whole family is revoked and named; anything else answers null.
368
- */
369
- consume(token: string): {
370
- readonly claims: CredentialClaims;
371
- } | {
372
- readonly reusedFamily: string | null;
373
- };
374
- revokeFamily(family: string): void;
375
- onRevoked(listener: (family: string) => void): () => void;
376
- /** {§credential-authority} The live browser sign-ins of `subject`, oldest first; never a token. */
377
- sessions(subject: string): readonly CredentialSession[];
378
- /**
379
- * Registers the calling module's own confidential client and answers its secret, minted for
380
- * this boot, held in memory and told to nobody else. A second registration of one id is a fault.
381
- */
382
- registerClient(client: ModuleClient): {
383
- readonly clientId: string;
384
- readonly clientSecret: string;
385
- };
386
- /** A module's registered client, without its secret; null for an id no module registered. */
387
- client(id: string): ModuleClient | null;
388
- /** Whether `secret` is the one minted for the module client `id`, compared in constant time. */
389
- authenticateClient(id: string, secret: string): boolean;
390
- /** {§auth-oauth-clients} Persists a dynamically registered RFC 7591 public client across restarts. */
391
- registerPublicClient?(client: PublicOAuthClient): void;
392
- /** {§auth-oauth-clients} Dynamically registered RFC 7591 public clients restored at boot. */
393
- publicClients?(): readonly PublicOAuthClient[];
394
- /**
395
- * {§auth-oauth-clients} Retains persisted credentials only for `allowedClientIds` (plus registered
396
- * module clients), revoking any family whose client was removed from configuration before restart.
397
- */
398
- retainClients?(allowedClientIds: ReadonlySet<string>): void;
399
- /** Publishes the one issuing face; a second publication is a configuration fault. */
309
+ /** Verifies a presented bearer token against the published face; null when invalid or unconfigured. */
310
+ verify(token: string): Promise<VerifiedBearerClaims | null> | VerifiedBearerClaims | null;
311
+ /** Publishes the one credential face; a second publication is a configuration fault. */
400
312
  publish(face: CredentialFace): void;
401
- /** The published face, or null while nothing issues: the daemon authenticates nothing. */
313
+ /** The published face, or null when no authentication module is active. */
402
314
  face(): CredentialFace | null;
403
315
  }
404
316
  export interface ApplicationPersonaProjection {