@inneranimalmedia/agentsam-sdk 2.6.8 → 2.6.10

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 (203) hide show
  1. package/README.md +18 -0
  2. package/apps/README.md +25 -0
  3. package/apps/cad-creator/shared/cad/package.json +1 -1
  4. package/apps/client-cms-editor/backend/package.json +5 -7
  5. package/apps/client-cms-editor/frontend/package.json +5 -7
  6. package/apps/client-cms-editor/frontend/tsconfig.json +27 -8
  7. package/apps/client-cms-editor/package-lock.json +8 -8
  8. package/apps/client-cms-editor/package.json +1 -1
  9. package/apps/client-cms-editor/shared/cms/package.json +3 -5
  10. package/docs/LOCAL_ENGINE_COMPUTE_AUDIT_PLAN.md +299 -0
  11. package/docs/architecture/HOOKS-MODELS-SELF-HOSTING-PLAN.md +199 -0
  12. package/examples/hyperspace-demo/index.html +16 -0
  13. package/examples/hyperspace-demo/package.json +21 -0
  14. package/examples/hyperspace-demo/src/main.tsx +160 -0
  15. package/examples/hyperspace-demo/tsconfig.json +9 -0
  16. package/examples/hyperspace-demo/vite.config.ts +24 -0
  17. package/migrations/runtime/0005_agentsam_hooks.sql +87 -0
  18. package/package.json +37 -10
  19. package/packages/agentsam-brand/package.json +1 -1
  20. package/packages/agentsam-brand/src/core/v2/compile.js +1 -1
  21. package/packages/agentsam-brand/src/core/v2/schema.js +1 -1
  22. package/packages/agentsam-contracts/package.json +71 -20
  23. package/packages/agentsam-contracts/scripts/build.mjs +18 -0
  24. package/packages/agentsam-contracts/src/errors.ts +19 -10
  25. package/packages/agentsam-contracts/test/contracts.test.mjs +4 -1
  26. package/packages/agentsam-contracts/test/repository.test.mjs +4 -1
  27. package/packages/agentsam-contracts/tsconfig.build.json +10 -0
  28. package/packages/agentsam-errors/package.json +13 -4
  29. package/packages/agentsam-errors/protocol/agentsam.error.v2.schema.json +821 -0
  30. package/packages/agentsam-errors/protocol/error-catalog.json +3512 -0
  31. package/packages/agentsam-errors/src/envelope.js +63 -11
  32. package/packages/agentsam-errors/src/error.js +6 -0
  33. package/packages/agentsam-errors/src/fingerprint.js +9 -1
  34. package/packages/agentsam-errors/src/normalize.js +51 -6
  35. package/packages/agentsam-errors/src/recovery.js +9 -35
  36. package/packages/agentsam-errors/src/transport.js +6 -1
  37. package/packages/agentsam-errors/src/vocabulary.js +515 -126
  38. package/packages/agentsam-errors/test/catalog-v2.test.mjs +106 -0
  39. package/packages/agentsam-errors/types/index.d.ts +157 -0
  40. package/packages/agentsam-goap/package.json +2 -2
  41. package/packages/agentsam-hooks/README.md +206 -0
  42. package/packages/agentsam-hooks/bin/agentsam-hooks.mjs +64 -0
  43. package/packages/agentsam-hooks/bindings/go/command.go +55 -0
  44. package/packages/agentsam-hooks/bindings/go/errors_generated.go +402 -0
  45. package/packages/agentsam-hooks/bindings/go/go.mod +3 -0
  46. package/packages/agentsam-hooks/bindings/go/hooks.go +285 -0
  47. package/packages/agentsam-hooks/bindings/go/hooks_test.go +48 -0
  48. package/packages/agentsam-hooks/bindings/rust/Cargo.toml +11 -0
  49. package/packages/agentsam-hooks/bindings/rust/src/errors_generated.rs +396 -0
  50. package/packages/agentsam-hooks/bindings/rust/src/lib.rs +397 -0
  51. package/packages/agentsam-hooks/package.json +69 -0
  52. package/packages/agentsam-hooks/schema/manifest.json +54 -0
  53. package/packages/agentsam-hooks/scripts/clean-protocol.mjs +17 -0
  54. package/packages/agentsam-hooks/scripts/sync-protocol.mjs +27 -0
  55. package/packages/agentsam-hooks/src/adapters/agents.js +82 -0
  56. package/packages/agentsam-hooks/src/adapters/callback.js +4 -0
  57. package/packages/agentsam-hooks/src/adapters/capability.js +122 -0
  58. package/packages/agentsam-hooks/src/adapters/command.js +104 -0
  59. package/packages/agentsam-hooks/src/adapters/composite.js +31 -0
  60. package/packages/agentsam-hooks/src/adapters/http.js +58 -0
  61. package/packages/agentsam-hooks/src/adapters/lsp.js +116 -0
  62. package/packages/agentsam-hooks/src/adapters/mcp.js +76 -0
  63. package/packages/agentsam-hooks/src/adapters/provider.js +129 -0
  64. package/packages/agentsam-hooks/src/config.js +143 -0
  65. package/packages/agentsam-hooks/src/contracts.js +284 -0
  66. package/packages/agentsam-hooks/src/errors-generated.js +2732 -0
  67. package/packages/agentsam-hooks/src/index.d.ts +193 -0
  68. package/packages/agentsam-hooks/src/index.js +14 -0
  69. package/packages/agentsam-hooks/src/policy.js +34 -0
  70. package/packages/agentsam-hooks/src/runtime.js +312 -0
  71. package/packages/agentsam-hooks/src/store.js +264 -0
  72. package/packages/agentsam-hooks/test/adapters.test.mjs +216 -0
  73. package/packages/agentsam-hooks/test/runtime.test.mjs +258 -0
  74. package/packages/agentsam-knowledge/package.json +3 -2
  75. package/packages/agentsam-nav/package.json +1 -1
  76. package/packages/agentsam-queue-control/package.json +1 -1
  77. package/packages/agentsam-rapid-rust/src/main.rs +1 -0
  78. package/packages/agentsam-repository/package.json +3 -2
  79. package/packages/agentsam-vault/package.json +8 -5
  80. package/packages/agentsam-workbench/package.json +45 -18
  81. package/packages/connectors/cloudflare/package.json +1 -1
  82. package/packages/heuristic-theme/package.json +1 -1
  83. package/packages/identity/package.json +3 -2
  84. package/packages/identity/tests/lane1-packed-consumer.test.mjs +9 -1
  85. package/packages/providers/completeful/package.json +1 -1
  86. package/packages/theme-church-site/README.md +2 -2
  87. package/packages/theme-church-site/package.json +2 -3
  88. package/packages/theme-church-site/src/index.js +1 -1
  89. package/packages/theme-church-site/test/theme.test.mjs +1 -1
  90. package/packages/theme-companions-site/README.md +2 -2
  91. package/packages/theme-companions-site/package.json +2 -3
  92. package/packages/theme-companions-site/src/index.js +1 -1
  93. package/packages/theme-companions-site/test/theme.test.mjs +1 -1
  94. package/packages/theme-floors-site/README.md +2 -2
  95. package/packages/theme-floors-site/package.json +2 -3
  96. package/packages/theme-floors-site/src/index.js +1 -1
  97. package/packages/theme-floors-site/test/theme.test.mjs +1 -1
  98. package/packages/theme-fuelnfree-site/README.md +2 -2
  99. package/packages/theme-fuelnfree-site/package.json +2 -3
  100. package/packages/theme-fuelnfree-site/src/index.js +1 -1
  101. package/packages/theme-fuelnfree-site/test/theme.test.mjs +1 -1
  102. package/packages/theme-handyman-site/README.md +2 -2
  103. package/packages/theme-handyman-site/package.json +2 -3
  104. package/packages/theme-handyman-site/src/index.js +1 -1
  105. package/packages/theme-handyman-site/test/theme.test.mjs +1 -1
  106. package/packages/theme-insurance-site/README.md +2 -2
  107. package/packages/theme-insurance-site/package.json +2 -3
  108. package/packages/theme-insurance-site/src/index.js +1 -1
  109. package/packages/theme-insurance-site/test/theme.test.mjs +1 -1
  110. package/packages/theme-scenes/package.json +1 -1
  111. package/packages/theme-shinshu-site/README.md +2 -2
  112. package/packages/theme-shinshu-site/package.json +2 -3
  113. package/packages/theme-shinshu-site/src/index.js +1 -1
  114. package/packages/theme-shinshu-site/test/theme.test.mjs +1 -1
  115. package/packages/work-graph/package.json +3 -2
  116. package/protocol/apps/agentsam.app.v1.schema.json +1 -1
  117. package/protocol/apps/agentsam.host-install.v1.schema.json +1 -1
  118. package/protocol/assets/asset-record.v1.schema.json +1 -1
  119. package/protocol/brand/brandpack.v1.schema.json +1 -1
  120. package/protocol/capabilities/capability-manifest.schema.json +1 -1
  121. package/protocol/capabilities/knowledge-search-input.schema.json +1 -0
  122. package/protocol/credentials/issue.v1.schema.json +1 -1
  123. package/protocol/database/agentsam.schema-pack.v1.schema.json +1 -1
  124. package/protocol/database/connection.v1.schema.json +1 -1
  125. package/protocol/embeddings/embedding-profile.v1.schema.json +1 -1
  126. package/protocol/errors/README.md +36 -0
  127. package/protocol/errors/agentsam.error.v2.schema.json +821 -0
  128. package/protocol/errors/error-catalog.json +3506 -158
  129. package/protocol/errors/error-envelope.schema.json +195 -52
  130. package/protocol/errors/recovery.v1.schema.json +1 -1
  131. package/protocol/features/agentsam.feature.v1.schema.json +1 -1
  132. package/protocol/hooks/README.md +18 -0
  133. package/protocol/hooks/agentsam.hook.output.v1.schema.json +27 -0
  134. package/protocol/hooks/agentsam.hook.receipt.v1.schema.json +61 -0
  135. package/protocol/hooks/agentsam.hook.v1.schema.json +35 -0
  136. package/protocol/hooks/agentsam.hooks.config.v1.schema.json +78 -0
  137. package/protocol/local-engine/benchmark.v1.schema.json +14 -0
  138. package/protocol/local-engine/engine.v1.schema.json +17 -0
  139. package/protocol/models/model-inventory-v2.schema.json +1 -1
  140. package/protocol/models/provider-model-snapshot.v1.schema.json +22 -0
  141. package/protocol/rpc/v1/errors.proto +1 -0
  142. package/protocol/runtime/agentsam.runtime.v1.schema.json +1 -1
  143. package/protocol/runtime/workspace-fs.v1.schema.json +1 -1
  144. package/protocol/sam/activity.v1.schema.json +1 -1
  145. package/protocol/sam/answer.v1.schema.json +1 -1
  146. package/protocol/sam/calibration.v1.schema.json +1 -1
  147. package/protocol/sam/decision-receipt.v1.schema.json +1 -1
  148. package/protocol/sam/evaluation.v1.schema.json +1 -1
  149. package/protocol/sam/operation.schema.json +1 -1
  150. package/protocol/sam/outcome.v1.schema.json +1 -1
  151. package/protocol/sam/question.v1.schema.json +1 -1
  152. package/protocol/sam/result.schema.json +1 -1
  153. package/protocol/sam/state.v1.schema.json +1 -1
  154. package/protocol/scoring/scorecard.v1.schema.json +1 -1
  155. package/protocol/skills/agentsam.interaction.v1.schema.json +1 -1
  156. package/protocol/skills/agentsam.skill.v1.schema.json +1 -1
  157. package/protocol/theme-refinery/product-metadata.schema.json +1 -1
  158. package/protocol/theme-refinery/reconciliation-receipt.schema.json +1 -1
  159. package/protocol/ui/icon.v1.schema.json +1 -1
  160. package/python/README.md +20 -0
  161. package/python/agentsam_sdk/errors/__init__.py +4 -0
  162. package/python/agentsam_sdk/errors/vocabulary.py +2730 -0
  163. package/python/agentsam_sdk/hooks/__init__.py +32 -0
  164. package/python/agentsam_sdk/hooks/adapters.py +132 -0
  165. package/python/agentsam_sdk/hooks/contracts.py +121 -0
  166. package/python/agentsam_sdk/hooks/runtime.py +253 -0
  167. package/python/tests/test_hooks.py +115 -0
  168. package/src/agent/responses-runner.js +145 -1
  169. package/src/cli/command-catalog.js +2 -0
  170. package/src/cli.js +19 -0
  171. package/src/commands/app.js +10 -0
  172. package/src/commands/cheat-sheet.js +1 -0
  173. package/src/commands/engine.js +10 -0
  174. package/src/commands/hooks.js +260 -0
  175. package/src/commands/machine.js +71 -38
  176. package/src/commands/models.js +1 -1
  177. package/src/commands/package.js +10 -3
  178. package/src/commands/runtime.js +25 -10
  179. package/src/commands/setup.js +30 -6
  180. package/src/commands/shell.js +114 -9
  181. package/src/commands/terminal.js +20 -8
  182. package/src/errors/contract.js +4 -4
  183. package/src/errors/diagnostic.js +10 -10
  184. package/src/errors/index.js +1 -1
  185. package/src/index.js +52 -0
  186. package/src/indexing/ingest/materials.js +237 -30
  187. package/src/knowledge/service/grpc-codec.js +2 -0
  188. package/src/lib/setup/runtime.js +4 -2
  189. package/src/lib/slash-commands.js +1 -0
  190. package/src/local/runtime-store.js +46 -0
  191. package/src/local-engine/assets.js +37 -0
  192. package/src/local-engine/audit.js +133 -0
  193. package/src/local-engine/benchmark.js +26 -0
  194. package/src/local-engine/contracts.js +101 -0
  195. package/src/local-engine/engines.js +142 -0
  196. package/src/local-engine/index.js +18 -0
  197. package/src/local-engine/runtime.js +39 -0
  198. package/src/models/catalog.js +0 -49
  199. package/src/models/inventory-core.js +69 -0
  200. package/src/plugins/index.js +8 -1
  201. package/src/plugins/registry.js +56 -0
  202. package/src/rpc/generated/errors_pb.js +49 -1
  203. package/src/tools/runtime.js +13 -5
@@ -1,4 +1,5 @@
1
1
  import { normalizePluginManifest } from './contracts.js';
2
+ import { createAiPluginProbePatch } from '../models/inventory-core.js';
2
3
 
3
4
  function clean(value) { return value == null ? '' : String(value).trim(); }
4
5
  function json(value, fallback) { try { return JSON.parse(String(value ?? '')); } catch { return fallback; } }
@@ -188,6 +189,61 @@ export async function recordPluginHealthCheck(db, value = {}) {
188
189
  return { id: checkId, status: value.status };
189
190
  }
190
191
 
192
+ /**
193
+ * Persist credential-verified AI model availability in the existing plugin
194
+ * installation metadata. A failed probe records health evidence but preserves
195
+ * the last successful model snapshot.
196
+ */
197
+ export async function recordAiPluginModelDiscovery(db, value = {}) {
198
+ if (!db?.prepare) throw new TypeError('D1-compatible database binding required');
199
+ const pluginId = clean(value.pluginId);
200
+ const accountId = clean(value.accountId);
201
+ if (!pluginId) throw new Error('plugin_id_required');
202
+ if (!accountId) throw new Error('plugin_account_id_required');
203
+ const plugin = await db.prepare(`
204
+ SELECT id, plugin_key, provider_key, environment, plugin_kind, metadata_json
205
+ FROM agentsam_plugins WHERE id = ? AND account_id = ? LIMIT 1
206
+ `).bind(pluginId, accountId).first();
207
+ if (!plugin) throw new Error(`plugin_not_found:${pluginId}`);
208
+ if (clean(plugin.plugin_kind) !== 'ai') throw new Error(`plugin_not_ai:${pluginId}`);
209
+
210
+ const probe = createAiPluginProbePatch(json(plugin.metadata_json, {}), value.discovery || {}, {
211
+ provider: value.provider || plugin.provider_key,
212
+ fetchedAtUnix: value.completedAt,
213
+ });
214
+ await runMutation(db, `
215
+ UPDATE agentsam_plugins SET metadata_json = ?, updated_at = unixepoch()
216
+ WHERE id = ? AND account_id = ?
217
+ `, [JSON.stringify(probe.metadata), pluginId, accountId]);
218
+
219
+ const snapshot = probe.metadata.model_snapshot || null;
220
+ const health = await recordPluginHealthCheck(db, {
221
+ pluginId,
222
+ pluginKey: plugin.plugin_key,
223
+ accountId,
224
+ environment: plugin.environment,
225
+ checkKind: 'model_inventory',
226
+ checkSource: value.checkSource || 'provider_discovery',
227
+ status: probe.health_status,
228
+ startedAt: value.startedAt,
229
+ completedAt: probe.last_health_at,
230
+ latencyMs: value.latencyMs,
231
+ httpStatus: value.httpStatus,
232
+ providerRequestId: value.providerRequestId,
233
+ errorCode: probe.last_error_code,
234
+ errorMessage: probe.last_error_message,
235
+ details: snapshot ? {
236
+ schema: snapshot.schema,
237
+ provider: snapshot.provider,
238
+ model_count: snapshot.model_count,
239
+ models_hash: snapshot.models_hash,
240
+ fetched_at_unix: snapshot.fetched_at_unix,
241
+ ...(value.discovery?.ok === true ? {} : { snapshot_preserved: true }),
242
+ } : { provider: clean(value.provider || plugin.provider_key), snapshot_preserved: true },
243
+ });
244
+ return Object.freeze({ ...health, plugin_id: pluginId, health_status: probe.health_status, model_snapshot: snapshot });
245
+ }
246
+
191
247
  export async function recordToolCall(db, value = {}) {
192
248
  const callId = clean(value.id) || id('atcl');
193
249
  await runMutation(db, `
@@ -103,7 +103,8 @@ proto.agentsam.knowledge.v1.ErrorDetail.toObject = function(includeInstance, msg
103
103
  detailsJson: jspb.Message.getFieldWithDefault(msg, 25, ""),
104
104
  occurrenceCount: jspb.Message.getFieldWithDefault(msg, 26, 0),
105
105
  requestId: jspb.Message.getFieldWithDefault(msg, 27, ""),
106
- schemaVersion: jspb.Message.getFieldWithDefault(msg, 28, 0)
106
+ schemaVersion: jspb.Message.getFieldWithDefault(msg, 28, 0),
107
+ nativeStage: jspb.Message.getFieldWithDefault(msg, 29, "")
107
108
  };
108
109
 
109
110
  if (includeInstance) {
@@ -252,6 +253,10 @@ proto.agentsam.knowledge.v1.ErrorDetail.deserializeBinaryFromReader = function(m
252
253
  var value = /** @type {number} */ (reader.readUint32());
253
254
  msg.setSchemaVersion(value);
254
255
  break;
256
+ case 29:
257
+ var value = /** @type {string} */ (reader.readString());
258
+ msg.setNativeStage(value);
259
+ break;
255
260
  default:
256
261
  reader.skipField();
257
262
  break;
@@ -477,6 +482,13 @@ proto.agentsam.knowledge.v1.ErrorDetail.serializeBinaryToWriter = function(messa
477
482
  f
478
483
  );
479
484
  }
485
+ f = /** @type {string} */ (jspb.Message.getField(message, 29));
486
+ if (f != null) {
487
+ writer.writeString(
488
+ 29,
489
+ f
490
+ );
491
+ }
480
492
  };
481
493
 
482
494
 
@@ -1416,6 +1428,42 @@ proto.agentsam.knowledge.v1.ErrorDetail.prototype.hasSchemaVersion = function()
1416
1428
  };
1417
1429
 
1418
1430
 
1431
+ /**
1432
+ * optional string native_stage = 29;
1433
+ * @return {string}
1434
+ */
1435
+ proto.agentsam.knowledge.v1.ErrorDetail.prototype.getNativeStage = function() {
1436
+ return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 29, ""));
1437
+ };
1438
+
1439
+
1440
+ /**
1441
+ * @param {string} value
1442
+ * @return {!proto.agentsam.knowledge.v1.ErrorDetail} returns this
1443
+ */
1444
+ proto.agentsam.knowledge.v1.ErrorDetail.prototype.setNativeStage = function(value) {
1445
+ return jspb.Message.setField(this, 29, value);
1446
+ };
1447
+
1448
+
1449
+ /**
1450
+ * Clears the field making it undefined.
1451
+ * @return {!proto.agentsam.knowledge.v1.ErrorDetail} returns this
1452
+ */
1453
+ proto.agentsam.knowledge.v1.ErrorDetail.prototype.clearNativeStage = function() {
1454
+ return jspb.Message.setField(this, 29, undefined);
1455
+ };
1456
+
1457
+
1458
+ /**
1459
+ * Returns whether this field is set.
1460
+ * @return {boolean}
1461
+ */
1462
+ proto.agentsam.knowledge.v1.ErrorDetail.prototype.hasNativeStage = function() {
1463
+ return jspb.Message.getField(this, 29) != null;
1464
+ };
1465
+
1466
+
1419
1467
  /**
1420
1468
  * @enum {number}
1421
1469
  */
@@ -1,4 +1,4 @@
1
- import { ERROR_REASON_POLICY, normalizeError } from '../errors/index.js';
1
+ import { ERROR_REASON_POLICY, canonicalizeErrorReason, normalizeError } from '../errors/index.js';
2
2
  import { receiptPayload, redactToolValue } from './redact.js';
3
3
 
4
4
  function defaultId(prefix) {
@@ -6,6 +6,11 @@ function defaultId(prefix) {
6
6
  }
7
7
 
8
8
  function reasonForError(error) {
9
+ const nativeReason = canonicalizeErrorReason(error);
10
+ if (/^(hook|mcp|lsp|tool|provider)_/.test(nativeReason || '')) return nativeReason;
11
+ const message = String(error?.message || error || '').toLowerCase();
12
+ if (message.includes('provider adapter not registered') || message.includes('no registered execution target')) return 'tool_handler_unavailable';
13
+ if (/timeout|timed out|deadline/.test(message)) return 'tool_timeout';
9
14
  const status = Number(error?.status || error?.http_status || 0);
10
15
  if (status === 401) return 'provider_credential_invalid';
11
16
  if (status === 403) return 'provider_scope_insufficient';
@@ -16,12 +21,12 @@ function reasonForError(error) {
16
21
  if (status === 400 || status === 422) return 'provider_request_invalid';
17
22
  if (error?.code === 'completeful_idempotency_required') return 'input_invalid';
18
23
  if (error instanceof TypeError) return 'input_invalid';
19
- return 'execution_failed';
24
+ return nativeReason || 'tool_execution_failed';
20
25
  }
21
26
 
22
- function normalizeToolError(error, definition) {
27
+ function normalizeToolError(error, definition, sideEffectState = 'unknown') {
23
28
  const reason = reasonForError(error);
24
- const policy = ERROR_REASON_POLICY[reason] || ERROR_REASON_POLICY.execution_failed;
29
+ const policy = ERROR_REASON_POLICY[reason] || ERROR_REASON_POLICY.tool_execution_failed;
25
30
  return normalizeError(error, {
26
31
  code: policy.code,
27
32
  reason,
@@ -29,6 +34,9 @@ function normalizeToolError(error, definition) {
29
34
  ? { kind: 'provider', name: definition.provider, service: definition.provider }
30
35
  : { kind: 'runtime', name: 'agentsam-tool-runtime' },
31
36
  domain: 'tool',
37
+ stage: 'execute',
38
+ feature: 'tool.execute',
39
+ side_effect_state: sideEffectState,
32
40
  tool: definition.toolKey,
33
41
  provider: definition.provider || null,
34
42
  provider_code: error?.code || null,
@@ -132,7 +140,7 @@ export function createToolExecutor({
132
140
  try {
133
141
  invoke = await resolveExecutionTarget(registry, definition);
134
142
  } catch (error) {
135
- const normalized = normalizeToolError(error, definition);
143
+ const normalized = normalizeToolError(error, definition, 'not_started');
136
144
  const completedAt = now();
137
145
  const receipt = {
138
146
  invocationId: invocation.id,