@lobu/runtime-device 24.2.0 → 24.4.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 (72) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +43 -129
  3. package/npm-shrinkwrap.json +206 -690
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +21 -3
  6. package/vendor/cli/dist/bundled-skills/lobu-connect/SKILL.md +6 -0
  7. package/vendor/cli/dist/commands/chat.d.ts +0 -12
  8. package/vendor/cli/dist/commands/chat.js +1 -1
  9. package/vendor/cli/dist/commands/daemon.js +36 -19
  10. package/vendor/cli/dist/commands/doctor.d.ts +0 -6
  11. package/vendor/cli/dist/commands/doctor.js +1 -1
  12. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.d.ts +0 -8
  13. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +1 -1
  14. package/vendor/cli/dist/config/define.d.ts +1 -1
  15. package/vendor/cli/dist/connectors/gchat.ts +31 -1
  16. package/vendor/cli/dist/connectors/postgres.ts +9 -5
  17. package/vendor/cli/dist/internal/cli-update-check.d.ts +33 -0
  18. package/vendor/cli/dist/internal/cli-update-check.js +98 -0
  19. package/vendor/cli/dist/internal/credentials.js +10 -36
  20. package/vendor/cli/dist/internal/gateway-url.d.ts +0 -8
  21. package/vendor/cli/dist/internal/gateway-url.js +1 -1
  22. package/vendor/cli/dist/runtime-components.json +4 -4
  23. package/vendor/cli/package.json +1 -1
  24. package/vendor/connector-sdk/dist/connector-types.d.ts +29 -0
  25. package/vendor/connector-sdk/dist/index.d.ts +3 -1
  26. package/vendor/connector-sdk/dist/index.js +4 -0
  27. package/vendor/connector-sdk/dist/redact.d.ts +10 -0
  28. package/vendor/{connector-worker/dist/executor → connector-sdk/dist}/redact.js +0 -49
  29. package/vendor/connector-sdk/dist/types.d.ts +2 -1
  30. package/vendor/connector-sdk/package.json +6 -1
  31. package/vendor/connector-worker/dist/daemon/acp-adapters/THIRD_PARTY_LICENSES.txt +1 -1
  32. package/vendor/connector-worker/dist/daemon/acp-adapters/claude.js +7339 -2136
  33. package/vendor/connector-worker/dist/daemon/agent-turn.js +58 -3
  34. package/vendor/connector-worker/dist/daemon/automation.js +1 -1
  35. package/vendor/connector-worker/dist/daemon/client.d.ts +15 -1
  36. package/vendor/connector-worker/dist/daemon/client.js +57 -4
  37. package/vendor/connector-worker/dist/daemon/executor.d.ts +0 -28
  38. package/vendor/connector-worker/dist/daemon/executor.js +27 -12
  39. package/vendor/connector-worker/dist/daemon/index.d.ts +1 -1
  40. package/vendor/connector-worker/dist/daemon/index.js +1 -1
  41. package/vendor/connector-worker/dist/daemon/log.js +2 -1
  42. package/vendor/connector-worker/dist/daemon/poll-loop.js +32 -8
  43. package/vendor/connector-worker/dist/daemon/start.d.ts +0 -1
  44. package/vendor/connector-worker/dist/daemon/start.js +1 -1
  45. package/vendor/connector-worker/dist/daemon/terminal-delivery.d.ts +1 -0
  46. package/vendor/connector-worker/dist/daemon/terminal-delivery.js +10 -6
  47. package/vendor/connector-worker/dist/executor/isolate.js +1 -1
  48. package/vendor/connector-worker/dist/isolate/bridge.d.ts +6 -2
  49. package/vendor/connector-worker/dist/isolate/bridge.js +14 -8
  50. package/vendor/connector-worker/package.json +2 -2
  51. package/vendor/core/dist/connector-query-errors.d.ts +6 -0
  52. package/vendor/core/dist/connector-query-errors.js +4 -0
  53. package/vendor/core/dist/contracts/tools/manage-automations.js +1 -1
  54. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
  55. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +49 -20
  56. package/vendor/core/dist/contracts/tools/manage-entity.js +23 -5
  57. package/vendor/core/dist/contracts/worker/device-automation.d.ts +1 -1
  58. package/vendor/core/dist/contracts/worker/device-automation.js +1 -1
  59. package/vendor/core/dist/errors.d.ts +0 -20
  60. package/vendor/core/dist/errors.js +1 -25
  61. package/vendor/core/dist/index.d.ts +1 -0
  62. package/vendor/core/dist/index.js +4 -1
  63. package/vendor/core/dist/logger.js +8 -2
  64. package/vendor/core/dist/otel.d.ts +13 -2
  65. package/vendor/core/dist/otel.js +98 -44
  66. package/vendor/core/dist/trace-context.d.ts +12 -0
  67. package/vendor/core/dist/trace-context.js +50 -0
  68. package/vendor/core/dist/utils/ajv.js +3 -1
  69. package/vendor/core/package.json +26 -5
  70. package/vendor/connector-worker/dist/executor/http-status.d.ts +0 -16
  71. package/vendor/connector-worker/dist/executor/http-status.js +0 -21
  72. package/vendor/connector-worker/dist/executor/redact.d.ts +0 -29
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-worker",
3
- "version": "24.2.0",
3
+ "version": "24.4.0",
4
4
  "description": "Self-hosted worker for Lobu memory — connectors and embedding generation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -70,7 +70,7 @@
70
70
  "esbuild": "^0.28.1",
71
71
  "just-bash": "^2.14.2",
72
72
  "pathe": "^2.0.3",
73
- "undici": "7.29.1"
73
+ "undici": "7.30.1"
74
74
  },
75
75
  "optionalDependencies": {
76
76
  "isolated-vm": "^6.2.0",
@@ -30,6 +30,12 @@ export type ToolErrorCode =
30
30
  | "VALIDATION"
31
31
  /** Denied by org-scope / cross-org visibility rules. */
32
32
  | "PERMISSION"
33
+ /**
34
+ * `manage_entity update` sent `manual_edit: true`, but the caller may not
35
+ * assert a person's edit: it lacks the `entities:manual_edit` scope, or an
36
+ * agent, MCP session or Automation is behind the call (HTTP 403).
37
+ */
38
+ | "MANUAL_EDIT_NOT_ALLOWED"
33
39
  /** Upstream throttled the request (HTTP 429 / too many requests). */
34
40
  | "RATE_LIMITED"
35
41
  /** Upstream request or DB statement timed out (e.g. PG 57014). */
@@ -50,6 +50,10 @@ exports.TOOL_ERRORS = {
50
50
  retryable: false,
51
51
  message: "Not permitted in this organization scope.",
52
52
  },
53
+ MANUAL_EDIT_NOT_ALLOWED: {
54
+ retryable: false,
55
+ message: "This caller may not assert a manual edit; it needs the entities:manual_edit scope and no agent, MCP session or Automation behind it.",
56
+ },
53
57
  RATE_LIMITED: {
54
58
  retryable: true,
55
59
  message: "The upstream rate limit was hit; retry shortly.",
@@ -122,7 +122,7 @@ exports.AutomationScheduleTriggerSchema = typebox_1.Type.Object({
122
122
  })),
123
123
  skip_if_unchanged: typebox_1.Type.Optional(typebox_1.Type.Boolean({
124
124
  default: true,
125
- description: "Native executors may skip unchanged source windows. External executors always receive due windows and decide whether to emit output.",
125
+ description: "Book a due window with no new or changed source content as a no-op run instead of dispatching an agent. Applies to native dispatch and to external claimNextWindow, which answers 409 for a skipped window.",
126
126
  })),
127
127
  }, { additionalProperties: false });
128
128
  exports.AutomationTriggerSchema = typebox_1.Type.Union([
@@ -114,7 +114,7 @@ exports.ManageEntitySchemaSchema = typebox_1.Type.Object({
114
114
  interactions: typebox_1.Type.Optional(typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.Object({ emits: typebox_1.Type.String() }))),
115
115
  })),
116
116
  ], {
117
- description: "[entity_type: create/update] Event semantic types this type produces, keyed by semantic_type slug. Each entry can have a description, optional metadataSchema (JSON Schema), optional jsonTemplate (the event card's render template), and optional interactions registry mapping template action names to emitted event kinds. Author interactive dashboards as React views attached to the kind (views.set with attach [{ event_kind }]), not as jsonTemplate. Supplying an object replaces the entire registry: read the current value and merge before updating. `null` clears all kinds; omit to leave unchanged.",
117
+ description: "[entity_type: create/update] Event semantic types this type produces, keyed by semantic_type slug. Each entry can have a description, optional metadataSchema (JSON Schema), optional jsonTemplate (the event card's render template), and optional interactions registry mapping template action names to emitted event kinds. Author interactive dashboards as React views attached to the kind (views.set with attach [{ event: '<kind>' }]), not as jsonTemplate. Supplying an object replaces the entire registry: read the current value and merge before updating. `null` clears all kinds; omit to leave unchanged.",
118
118
  })),
119
119
  backing: typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Null(), exports.BackingInputSchema], {
120
120
  description: "[entity_type: create/update] Makes the type DERIVED — a read-only SQL view. `{ sql }` runs over your org's internal tables; `{ sql, connection: <slug> }` runs LIVE against that connection's external database (read-only, no copy). `null` clears it (revert to a stored type); omit to leave unchanged. Read a derived type's rows by running its `backing_sql` (returned by `get`) through `query_sql` — and when `get` also returns a `backing_source`, pass it as `query_sql`'s `connection` so the view runs against the external DB instead of your internal tables. `get` also returns `measure_columns` (the view's aggregate columns, classified on read).",
@@ -24,6 +24,7 @@ export declare const UpdateEntityAction: import("@sinclair/typebox").TObject<{
24
24
  metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
25
25
  field_note: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
26
26
  affirm_fields: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
27
+ manual_edit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
27
28
  automation_source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
28
29
  automation_id: import("@sinclair/typebox").TNumber;
29
30
  run_id: import("@sinclair/typebox").TNumber;
@@ -56,7 +57,7 @@ export declare const ListEntitiesAction: import("@sinclair/typebox").TObject<{
56
57
  export declare const GetEntityAction: import("@sinclair/typebox").TObject<{
57
58
  action: import("@sinclair/typebox").TLiteral<"get">;
58
59
  entity_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>;
59
- entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
60
+ entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
60
61
  include_deleted: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
61
62
  }>;
62
63
  export declare const DeleteEntityAction: import("@sinclair/typebox").TObject<{
@@ -75,8 +76,8 @@ export declare const LinkEntitiesAction: import("@sinclair/typebox").TObject<{
75
76
  action: import("@sinclair/typebox").TLiteral<"link">;
76
77
  from_entity_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>;
77
78
  to_entity_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>;
78
- from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
79
- to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
79
+ from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
80
+ to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
80
81
  relationship_type_slug: import("@sinclair/typebox").TString;
81
82
  confidence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
82
83
  source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"ui">, import("@sinclair/typebox").TLiteral<"llm">, import("@sinclair/typebox").TLiteral<"feed">, import("@sinclair/typebox").TLiteral<"api">]>>;
@@ -96,8 +97,8 @@ export declare const UnlinkEntitiesAction: import("@sinclair/typebox").TObject<{
96
97
  relationship_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
97
98
  from_entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
98
99
  to_entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
99
- from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
100
- to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
100
+ from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
101
+ to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
101
102
  relationship_type_slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
102
103
  }>;
103
104
  export declare const UpdateLinkAction: import("@sinclair/typebox").TObject<{
@@ -105,8 +106,8 @@ export declare const UpdateLinkAction: import("@sinclair/typebox").TObject<{
105
106
  relationship_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
106
107
  from_entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
107
108
  to_entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
108
- from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
109
- to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
109
+ from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
110
+ to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
110
111
  relationship_type_slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
111
112
  confidence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
112
113
  source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"ui">, import("@sinclair/typebox").TLiteral<"llm">, import("@sinclair/typebox").TLiteral<"feed">, import("@sinclair/typebox").TLiteral<"api">]>>;
@@ -122,7 +123,7 @@ export declare const ListLinksAction: import("@sinclair/typebox").TObject<{
122
123
  offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
123
124
  action: import("@sinclair/typebox").TLiteral<"list_links">;
124
125
  entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
125
- entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
126
+ entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
126
127
  record: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
127
128
  type: import("@sinclair/typebox").TString;
128
129
  key: import("@sinclair/typebox").TString;
@@ -140,6 +141,11 @@ export declare const DiscoverDuplicatesAction: import("@sinclair/typebox").TObje
140
141
  cursor: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
141
142
  }>;
142
143
  export declare const ManageEntitySchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
144
+ action: import("@sinclair/typebox").TLiteral<"get">;
145
+ entity_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>;
146
+ entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
147
+ include_deleted: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
148
+ }>, import("@sinclair/typebox").TObject<{
143
149
  action: import("@sinclair/typebox").TLiteral<"create">;
144
150
  entity_type: import("@sinclair/typebox").TString;
145
151
  name: import("@sinclair/typebox").TString;
@@ -162,6 +168,7 @@ export declare const ManageEntitySchema: import("@sinclair/typebox").TUnion<[imp
162
168
  metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
163
169
  field_note: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
164
170
  affirm_fields: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
171
+ manual_edit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
165
172
  automation_source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
166
173
  automation_id: import("@sinclair/typebox").TNumber;
167
174
  run_id: import("@sinclair/typebox").TNumber;
@@ -189,11 +196,6 @@ export declare const ManageEntitySchema: import("@sinclair/typebox").TUnion<[imp
189
196
  parent_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TNull]>>;
190
197
  search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
191
198
  segment: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
192
- }>, import("@sinclair/typebox").TObject<{
193
- action: import("@sinclair/typebox").TLiteral<"get">;
194
- entity_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>;
195
- entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
196
- include_deleted: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
197
199
  }>, import("@sinclair/typebox").TObject<{
198
200
  action: import("@sinclair/typebox").TLiteral<"delete">;
199
201
  entity_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>;
@@ -209,8 +211,8 @@ export declare const ManageEntitySchema: import("@sinclair/typebox").TUnion<[imp
209
211
  action: import("@sinclair/typebox").TLiteral<"link">;
210
212
  from_entity_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>;
211
213
  to_entity_id: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>;
212
- from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
213
- to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
214
+ from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
215
+ to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
214
216
  relationship_type_slug: import("@sinclair/typebox").TString;
215
217
  confidence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
216
218
  source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"ui">, import("@sinclair/typebox").TLiteral<"llm">, import("@sinclair/typebox").TLiteral<"feed">, import("@sinclair/typebox").TLiteral<"api">]>>;
@@ -229,16 +231,16 @@ export declare const ManageEntitySchema: import("@sinclair/typebox").TUnion<[imp
229
231
  relationship_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
230
232
  from_entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
231
233
  to_entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
232
- from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
233
- to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
234
+ from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
235
+ to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
234
236
  relationship_type_slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
235
237
  }>, import("@sinclair/typebox").TObject<{
236
238
  action: import("@sinclair/typebox").TLiteral<"update_link">;
237
239
  relationship_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
238
240
  from_entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
239
241
  to_entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
240
- from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
241
- to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
242
+ from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
243
+ to_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
242
244
  relationship_type_slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
243
245
  confidence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
244
246
  source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"ui">, import("@sinclair/typebox").TLiteral<"llm">, import("@sinclair/typebox").TLiteral<"feed">, import("@sinclair/typebox").TLiteral<"api">]>>;
@@ -253,7 +255,7 @@ export declare const ManageEntitySchema: import("@sinclair/typebox").TUnion<[imp
253
255
  offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
254
256
  action: import("@sinclair/typebox").TLiteral<"list_links">;
255
257
  entity_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TString]>>;
256
- entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
258
+ entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TInteger]>>;
257
259
  record: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
258
260
  type: import("@sinclair/typebox").TString;
259
261
  key: import("@sinclair/typebox").TString;
@@ -290,6 +292,10 @@ export declare const RelationshipRowSchema: import("@sinclair/typebox").TObject<
290
292
  relationship_type_name: import("@sinclair/typebox").TString;
291
293
  is_symmetric: import("@sinclair/typebox").TBoolean;
292
294
  acl_managed: import("@sinclair/typebox").TBoolean;
295
+ from_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
296
+ to_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
297
+ from_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
298
+ to_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
293
299
  from_entity_name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
294
300
  from_entity_slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
295
301
  from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -330,6 +336,7 @@ export declare const ManageEntityItemSchema: import("@sinclair/typebox").TObject
330
336
  root_id: import("@sinclair/typebox").TInteger;
331
337
  member_ids: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TInteger>;
332
338
  }>>;
339
+ entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
333
340
  entity_type: import("@sinclair/typebox").TString;
334
341
  name: import("@sinclair/typebox").TString;
335
342
  slug: import("@sinclair/typebox").TString;
@@ -364,6 +371,7 @@ export declare const ManageEntityResultSchema: import("@sinclair/typebox").TUnio
364
371
  root_id: import("@sinclair/typebox").TInteger;
365
372
  member_ids: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TInteger>;
366
373
  }>>;
374
+ entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
367
375
  entity_type: import("@sinclair/typebox").TString;
368
376
  name: import("@sinclair/typebox").TString;
369
377
  slug: import("@sinclair/typebox").TString;
@@ -397,6 +405,7 @@ export declare const ManageEntityResultSchema: import("@sinclair/typebox").TUnio
397
405
  root_id: import("@sinclair/typebox").TInteger;
398
406
  member_ids: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TInteger>;
399
407
  }>>;
408
+ entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
400
409
  entity_type: import("@sinclair/typebox").TString;
401
410
  name: import("@sinclair/typebox").TString;
402
411
  slug: import("@sinclair/typebox").TString;
@@ -430,6 +439,8 @@ export declare const ManageEntityResultSchema: import("@sinclair/typebox").TUnio
430
439
  approval_current: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
431
440
  /** Who proposed the blocked change: 'agent' | 'automation'. */
432
441
  approval_attribution: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"automation" | "agent">[]>>;
442
+ /** True when a `manual_edit` assertion was honoured: the edit was recorded as the person's own. */
443
+ manual_edit_applied: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
433
444
  }>, import("@sinclair/typebox").TObject<{
434
445
  action: import("@sinclair/typebox").TLiteral<"list">;
435
446
  entities: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
@@ -438,6 +449,7 @@ export declare const ManageEntityResultSchema: import("@sinclair/typebox").TUnio
438
449
  root_id: import("@sinclair/typebox").TInteger;
439
450
  member_ids: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TInteger>;
440
451
  }>>;
452
+ entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
441
453
  entity_type: import("@sinclair/typebox").TString;
442
454
  name: import("@sinclair/typebox").TString;
443
455
  slug: import("@sinclair/typebox").TString;
@@ -477,6 +489,7 @@ export declare const ManageEntityResultSchema: import("@sinclair/typebox").TUnio
477
489
  root_id: import("@sinclair/typebox").TInteger;
478
490
  member_ids: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TInteger>;
479
491
  }>>;
492
+ entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
480
493
  entity_type: import("@sinclair/typebox").TString;
481
494
  name: import("@sinclair/typebox").TString;
482
495
  slug: import("@sinclair/typebox").TString;
@@ -543,6 +556,10 @@ export declare const ManageEntityResultSchema: import("@sinclair/typebox").TUnio
543
556
  relationship_type_name: import("@sinclair/typebox").TString;
544
557
  is_symmetric: import("@sinclair/typebox").TBoolean;
545
558
  acl_managed: import("@sinclair/typebox").TBoolean;
559
+ from_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
560
+ to_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
561
+ from_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
562
+ to_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
546
563
  from_entity_name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
547
564
  from_entity_slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
548
565
  from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -570,6 +587,10 @@ export declare const ManageEntityResultSchema: import("@sinclair/typebox").TUnio
570
587
  relationship_type_name: import("@sinclair/typebox").TString;
571
588
  is_symmetric: import("@sinclair/typebox").TBoolean;
572
589
  acl_managed: import("@sinclair/typebox").TBoolean;
590
+ from_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
591
+ to_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
592
+ from_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
593
+ to_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
573
594
  from_entity_name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
574
595
  from_entity_slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
575
596
  from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -617,6 +638,10 @@ export declare const ManageEntityResultSchema: import("@sinclair/typebox").TUnio
617
638
  relationship_type_name: import("@sinclair/typebox").TString;
618
639
  is_symmetric: import("@sinclair/typebox").TBoolean;
619
640
  acl_managed: import("@sinclair/typebox").TBoolean;
641
+ from_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
642
+ to_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
643
+ from_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
644
+ to_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
620
645
  from_entity_name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
621
646
  from_entity_slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
622
647
  from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -673,6 +698,10 @@ export declare const ManageEntityResultSchema: import("@sinclair/typebox").TUnio
673
698
  relationship_type_name: import("@sinclair/typebox").TString;
674
699
  is_symmetric: import("@sinclair/typebox").TBoolean;
675
700
  acl_managed: import("@sinclair/typebox").TBoolean;
701
+ from_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
702
+ to_entity_type_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
703
+ from_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
704
+ to_entity_url: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
676
705
  from_entity_name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
677
706
  from_entity_slug: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
678
707
  from_entity_type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
@@ -18,6 +18,10 @@ function SortOrderField(description) {
18
18
  const EntityType = typebox_1.Type.String({
19
19
  description: "Entity type as defined in your workspace",
20
20
  });
21
+ // Type names are local; a discovered numeric ID identifies one immutable type.
22
+ const EntityReferenceType = typebox_1.Type.Union([EntityType, typebox_1.Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER })], {
23
+ description: "[get/list_links and relationship endpoints] A local type slug or discovered numeric type ID. Other actions require a slug. Foreign IDs allow only public-record reads, not workspace access.",
24
+ });
21
25
  const EntityId = typebox_1.Type.Union([
22
26
  typebox_1.Type.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }),
23
27
  typebox_1.Type.String({ minLength: 1, maxLength: 1024 }),
@@ -74,8 +78,8 @@ const IncludeDeleted = typebox_1.Type.Boolean({
74
78
  const EdgeEndpoints = {
75
79
  from_entity_id: EntityId,
76
80
  to_entity_id: EntityId,
77
- from_entity_type: typebox_1.Type.Optional(EntityType),
78
- to_entity_type: typebox_1.Type.Optional(EntityType),
81
+ from_entity_type: typebox_1.Type.Optional(EntityReferenceType),
82
+ to_entity_type: typebox_1.Type.Optional(EntityReferenceType),
79
83
  relationship_type_slug: typebox_1.Type.String({
80
84
  description: "[link/unlink/update_link/list_links] Relationship type slug",
81
85
  minLength: 1,
@@ -128,6 +132,10 @@ exports.UpdateEntityAction = typebox_1.Type.Object({
128
132
  affirm_fields: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.String(), {
129
133
  description: "[update] Metadata field names whose CURRENT value the human approves as-is. No value change, but each is marked human-owned so an Automation can't later overwrite it without an approval. The 'approve' half of the recap feedback loop.",
130
134
  })),
135
+ // Asserted manual edit: a first-party backend records a person's own change
136
+ manual_edit: typebox_1.Type.Optional(typebox_1.Type.Boolean({
137
+ description: "[update] Assert that the signed-in person made this change themselves, so it is recorded as their manual edit: the fields it sets (and affirm_fields) become theirs, and Automations then queue an approval instead of updating them. A wrong assertion takes the field away from Automations. Honoured for a person's own web-session edit, or for a token minted with the entities:manual_edit scope by a person in the web app, with no agent, MCP session or Automation behind the call; otherwise the update fails with 403 MANUAL_EDIT_NOT_ALLOWED and nothing is written. Defaults to false.",
138
+ })),
131
139
  automation_source: typebox_1.Type.Optional(AutomationSource),
132
140
  });
133
141
  exports.ListEntitiesAction = typebox_1.Type.Object({
@@ -153,7 +161,7 @@ exports.ListEntitiesAction = typebox_1.Type.Object({
153
161
  exports.GetEntityAction = typebox_1.Type.Object({
154
162
  action: typebox_1.Type.Literal("get", { description: "Fetch one entity." }),
155
163
  entity_id: EntityId,
156
- entity_type: typebox_1.Type.Optional(EntityType),
164
+ entity_type: typebox_1.Type.Optional(EntityReferenceType),
157
165
  include_deleted: typebox_1.Type.Optional(IncludeDeleted),
158
166
  });
159
167
  exports.DeleteEntityAction = typebox_1.Type.Object({
@@ -244,7 +252,7 @@ exports.ListLinksAction = typebox_1.Type.Object({
244
252
  description: "List relationships for an entity with filters + counts.",
245
253
  }),
246
254
  entity_id: typebox_1.Type.Optional(EntityId),
247
- entity_type: typebox_1.Type.Optional(EntityType),
255
+ entity_type: typebox_1.Type.Optional(EntityReferenceType),
248
256
  record: typebox_1.Type.Optional(typebox_1.Type.Object({
249
257
  type: typebox_1.Type.String({ minLength: 1 }),
250
258
  key: typebox_1.Type.String({ minLength: 1 }),
@@ -283,10 +291,12 @@ exports.DiscoverDuplicatesAction = typebox_1.Type.Object({
283
291
  })),
284
292
  });
285
293
  exports.ManageEntitySchema = typebox_1.Type.Union([
294
+ // MCP flattens duplicate fields first-occurrence-wins: advertise the read
295
+ // selector superset while each mutation still validates its slug-only input.
296
+ exports.GetEntityAction,
286
297
  exports.CreateEntityAction,
287
298
  exports.UpdateEntityAction,
288
299
  exports.ListEntitiesAction,
289
- exports.GetEntityAction,
290
300
  exports.DeleteEntityAction,
291
301
  exports.LinkEntitiesAction,
292
302
  exports.UnlinkEntitiesAction,
@@ -321,6 +331,11 @@ exports.RelationshipRowSchema = typebox_1.Type.Object({
321
331
  // dead affordance this exists to remove. Every producer projects it from
322
332
  // the one shared RELATIONSHIP_SELECT, so no path needs to omit it.
323
333
  acl_managed: typebox_1.Type.Boolean(),
334
+ from_entity_type_id: typebox_1.Type.Optional(typebox_1.Type.Integer({ minimum: 1 })),
335
+ to_entity_type_id: typebox_1.Type.Optional(typebox_1.Type.Integer({ minimum: 1 })),
336
+ // Canonical links for foreign endpoints; same-workspace peeks are unchanged.
337
+ from_entity_url: typebox_1.Type.Optional(typebox_1.Type.String()),
338
+ to_entity_url: typebox_1.Type.Optional(typebox_1.Type.String()),
324
339
  from_entity_name: typebox_1.Type.Optional(typebox_1.Type.String()),
325
340
  from_entity_slug: typebox_1.Type.Optional(typebox_1.Type.String()),
326
341
  from_entity_type: typebox_1.Type.Optional(typebox_1.Type.String()),
@@ -359,6 +374,7 @@ exports.EntityIdentitySchema = typebox_1.Type.Object({
359
374
  exports.ManageEntityItemSchema = typebox_1.Type.Object({
360
375
  id: typebox_1.Type.Union([EntityId, typebox_1.Type.Null()]),
361
376
  identity: typebox_1.Type.Optional(exports.EntityIdentitySchema),
377
+ entity_type_id: typebox_1.Type.Optional(typebox_1.Type.Integer({ minimum: 1 })),
362
378
  entity_type: typebox_1.Type.String(),
363
379
  name: typebox_1.Type.String(),
364
380
  slug: typebox_1.Type.String(),
@@ -423,6 +439,8 @@ exports.ManageEntityResultSchema = typebox_1.Type.Union([
423
439
  approval_current: typebox_1.Type.Optional(typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.Unknown())),
424
440
  /** Who proposed the blocked change: 'agent' | 'automation'. */
425
441
  approval_attribution: typebox_1.Type.Optional(interaction_envelope_1.ApprovalAttributionSchema),
442
+ /** True when a `manual_edit` assertion was honoured: the edit was recorded as the person's own. */
443
+ manual_edit_applied: typebox_1.Type.Optional(typebox_1.Type.Boolean()),
426
444
  }),
427
445
  typebox_1.Type.Object({
428
446
  action: typebox_1.Type.Literal("list"),
@@ -8,7 +8,7 @@
8
8
  * headless args, flag mapping, MCP wiring). Adding a CLI is now one entry,
9
9
  * not a ~140-line executor copy.
10
10
  * - the Automation prompt builder — the completion contract the spawned CLI
11
- * must satisfy, pinned by golden-string fixtures in device-automation.test.ts.
11
+ * must satisfy.
12
12
  *
13
13
  * The connector-worker daemon consumes these from core. This module is pure
14
14
  * data + string building: it imports nothing above core.
@@ -9,7 +9,7 @@
9
9
  * headless args, flag mapping, MCP wiring). Adding a CLI is now one entry,
10
10
  * not a ~140-line executor copy.
11
11
  * - the Automation prompt builder — the completion contract the spawned CLI
12
- * must satisfy, pinned by golden-string fixtures in device-automation.test.ts.
12
+ * must satisfy.
13
13
  *
14
14
  * The connector-worker daemon consumes these from core. This module is pure
15
15
  * data + string building: it imports nothing above core.
@@ -39,26 +39,6 @@ export declare class OrchestratorError extends BaseError {
39
39
  static fromDatabaseError(error: any): OrchestratorError;
40
40
  toJSON(): Record<string, any>;
41
41
  }
42
- /**
43
- * Thrown when a worker spawn is declined because another replica already holds
44
- * the per-conversation lock for this turn — i.e. another pod legitimately OWNS
45
- * this conversation turn and is running it to completion.
46
- *
47
- * This is NOT a failure. It is the cross-pod "handled elsewhere" signal. Under
48
- * N>1 app replicas both pods drain the shared `thread_message` queue and race to
49
- * spawn the same per-conversation worker; exactly one wins the advisory lock.
50
- * The loser MUST drop silently — no user-facing error, no Critical log, no
51
- * retry (the winner holds the lock for the entire worker subprocess lifetime, so
52
- * retrying can never win). The winning pod discharges the shared turn-liveness
53
- * marker on its successful reply, so the user still receives the answer.
54
- *
55
- * Distinguished by type (not a magic message string) so the orchestrator can
56
- * tell "owned by another pod" apart from a genuine worker-startup failure (OOM,
57
- * spawn failure, bad config) which MUST still surface an error to the user.
58
- */
59
- export declare class ConversationOwnedElsewhereError extends BaseError {
60
- readonly name = "ConversationOwnedElsewhereError";
61
- }
62
42
  export declare class ConfigError extends BaseError {
63
43
  readonly name = "ConfigError";
64
44
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROVIDER_WINDOWED_QUOTA = exports.PROVIDER_BALANCE_EXHAUSTED = exports.AGENT_ERRORS = exports.AgentErrorCode = exports.ConfigError = exports.ConversationOwnedElsewhereError = exports.OrchestratorError = exports.ErrorCode = exports.WorkspaceError = exports.WorkerError = exports.BaseError = void 0;
3
+ exports.PROVIDER_WINDOWED_QUOTA = exports.PROVIDER_BALANCE_EXHAUSTED = exports.AGENT_ERRORS = exports.AgentErrorCode = exports.ConfigError = exports.OrchestratorError = exports.ErrorCode = exports.WorkspaceError = exports.WorkerError = exports.BaseError = void 0;
4
4
  exports.getErrorMessage = getErrorMessage;
5
5
  exports.toAgentErrorCode = toAgentErrorCode;
6
6
  /**
@@ -93,30 +93,6 @@ class OrchestratorError extends BaseError {
93
93
  }
94
94
  }
95
95
  exports.OrchestratorError = OrchestratorError;
96
- /**
97
- * Thrown when a worker spawn is declined because another replica already holds
98
- * the per-conversation lock for this turn — i.e. another pod legitimately OWNS
99
- * this conversation turn and is running it to completion.
100
- *
101
- * This is NOT a failure. It is the cross-pod "handled elsewhere" signal. Under
102
- * N>1 app replicas both pods drain the shared `thread_message` queue and race to
103
- * spawn the same per-conversation worker; exactly one wins the advisory lock.
104
- * The loser MUST drop silently — no user-facing error, no Critical log, no
105
- * retry (the winner holds the lock for the entire worker subprocess lifetime, so
106
- * retrying can never win). The winning pod discharges the shared turn-liveness
107
- * marker on its successful reply, so the user still receives the answer.
108
- *
109
- * Distinguished by type (not a magic message string) so the orchestrator can
110
- * tell "owned by another pod" apart from a genuine worker-startup failure (OOM,
111
- * spawn failure, bad config) which MUST still surface an error to the user.
112
- */
113
- class ConversationOwnedElsewhereError extends BaseError {
114
- constructor() {
115
- super(...arguments);
116
- this.name = "ConversationOwnedElsewhereError";
117
- }
118
- }
119
- exports.ConversationOwnedElsewhereError = ConversationOwnedElsewhereError;
120
96
  class ConfigError extends BaseError {
121
97
  constructor() {
122
98
  super(...arguments);
@@ -26,6 +26,7 @@ export * from "./logger";
26
26
  export * from "./modules";
27
27
  export type { OtelConfig, Span, Tracer } from "./otel";
28
28
  export { createChildSpan, createRootSpan, createSpan, flushTracing, getCurrentSpan, getTraceparent, getTracer, initTracing, runInSpanContext, SpanKind, SpanStatusCode, shutdownTracing, withChildSpan, withSpan, } from "./otel";
29
+ export { currentTraceLogFields, traceparentHeader } from "./trace-context";
29
30
  export type { ProviderConfigEntry, ProviderOAuthConfig, ProviderOAuthGrantKind, } from "./provider-config-types";
30
31
  export { isSdkCompat, type PiAiApi, resolveSdkCompat, SDK_COMPAT_PROTOCOLS, type SdkCompat, type SdkCompatProtocol, } from "./sdk-compat";
31
32
  export * from "./secret-refs";
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.withLobuFileParameters = exports.slugify = exports.titleFromSessionJsonl = exports.parseSessionEntries = exports.entryToMessage = exports.sanitizeSuggestionPrompts = exports.SUGGESTION_LIMITS = exports.isRefreshSuspended = exports.hasCredentialSource = exports.generateTraceId = exports.extractTraceId = exports.SDK_COMPAT_PROTOCOLS = exports.resolveSdkCompat = exports.isSdkCompat = exports.withSpan = exports.withChildSpan = exports.shutdownTracing = exports.SpanStatusCode = exports.SpanKind = exports.runInSpanContext = exports.initTracing = exports.getTracer = exports.getTraceparent = exports.getCurrentSpan = exports.flushTracing = exports.createSpan = exports.createRootSpan = exports.createChildSpan = exports.renderSkillMemorySection = exports.renderFallbackSystemContext = exports.BaseInstructionProvider = exports.CommandRegistry = exports.inferGrantKind = void 0;
19
+ exports.withLobuFileParameters = exports.slugify = exports.titleFromSessionJsonl = exports.parseSessionEntries = exports.entryToMessage = exports.sanitizeSuggestionPrompts = exports.SUGGESTION_LIMITS = exports.isRefreshSuspended = exports.hasCredentialSource = exports.generateTraceId = exports.extractTraceId = exports.SDK_COMPAT_PROTOCOLS = exports.resolveSdkCompat = exports.isSdkCompat = exports.traceparentHeader = exports.currentTraceLogFields = exports.withSpan = exports.withChildSpan = exports.shutdownTracing = exports.SpanStatusCode = exports.SpanKind = exports.runInSpanContext = exports.initTracing = exports.getTracer = exports.getTraceparent = exports.getCurrentSpan = exports.flushTracing = exports.createSpan = exports.createRootSpan = exports.createChildSpan = exports.renderSkillMemorySection = exports.renderFallbackSystemContext = exports.BaseInstructionProvider = exports.CommandRegistry = exports.inferGrantKind = void 0;
20
20
  __exportStar(require("./agent-policy"), exports);
21
21
  __exportStar(require("./tool-trace-summary"), exports);
22
22
  __exportStar(require("./shell-safety"), exports);
@@ -70,6 +70,9 @@ Object.defineProperty(exports, "SpanStatusCode", { enumerable: true, get: functi
70
70
  Object.defineProperty(exports, "shutdownTracing", { enumerable: true, get: function () { return otel_1.shutdownTracing; } });
71
71
  Object.defineProperty(exports, "withChildSpan", { enumerable: true, get: function () { return otel_1.withChildSpan; } });
72
72
  Object.defineProperty(exports, "withSpan", { enumerable: true, get: function () { return otel_1.withSpan; } });
73
+ var trace_context_1 = require("./trace-context");
74
+ Object.defineProperty(exports, "currentTraceLogFields", { enumerable: true, get: function () { return trace_context_1.currentTraceLogFields; } });
75
+ Object.defineProperty(exports, "traceparentHeader", { enumerable: true, get: function () { return trace_context_1.traceparentHeader; } });
73
76
  // Wire-protocol registry (sdkCompat → pi-ai adapter)
74
77
  var sdk_compat_1 = require("./sdk-compat");
75
78
  Object.defineProperty(exports, "isSdkCompat", { enumerable: true, get: function () { return sdk_compat_1.isSdkCompat; } });
@@ -10,6 +10,7 @@ const USE_WINSTON_LOGGER = process.env.USE_WINSTON_LOGGER === "true";
10
10
  // Use JSON format for structured logging (better for Loki parsing in production)
11
11
  const USE_JSON_FORMAT = process.env.LOG_FORMAT === "json";
12
12
  const winston_1 = __importDefault(require("winston"));
13
+ const trace_context_1 = require("./trace-context");
13
14
  const diagnostic_scrubber_1 = require("./utils/diagnostic-scrubber");
14
15
  function safeStringify(value, space) {
15
16
  try {
@@ -59,12 +60,14 @@ function createConsoleLogger(serviceName) {
59
60
  // all of these, and that coverage now lives here.
60
61
  msgStr = (0, diagnostic_scrubber_1.scrubDiagnosticValue)(String(message));
61
62
  }
63
+ const traceFields = (0, trace_context_1.currentTraceLogFields)();
62
64
  if (USE_JSON_FORMAT) {
63
65
  return safeStringify({
64
66
  timestamp,
65
67
  level: lvl,
66
68
  service: serviceName,
67
69
  release: process.env.APP_GIT_SHA,
70
+ ...traceFields,
68
71
  message: msgStr,
69
72
  ...(args.length > 0
70
73
  ? { data: args.length === 1 ? args[0] : args }
@@ -75,7 +78,10 @@ function createConsoleLogger(serviceName) {
75
78
  if (args.length > 0) {
76
79
  msgStr += ` ${safeStringify(args.length === 1 ? args[0] : args)}`;
77
80
  }
78
- return `[${timestamp.replace("T", " ").slice(0, 19)}] [${lvl}] [${serviceName}] ${msgStr}`;
81
+ const traced = traceFields.trace_id
82
+ ? ` trace_id=${traceFields.trace_id} span_id=${traceFields.span_id}`
83
+ : "";
84
+ return `[${timestamp.replace("T", " ").slice(0, 19)}] [${lvl}] [${serviceName}] ${msgStr}${traced}`;
79
85
  };
80
86
  return {
81
87
  error: (message, ...args) => {
@@ -131,7 +137,7 @@ function createLogger(serviceName) {
131
137
  format: winston_1.default.format.combine(winston_1.default.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), winston_1.default.format.errors({ stack: true }), winston_1.default.format.splat(), winston_1.default.format((info) => {
132
138
  // Preserve Winston's symbol fields while applying the same boundary
133
139
  // scrubbing as the default console transport.
134
- return Object.assign(info, (0, diagnostic_scrubber_1.scrubDiagnosticValue)(info));
140
+ return Object.assign(info, (0, diagnostic_scrubber_1.scrubDiagnosticValue)(info), (0, trace_context_1.currentTraceLogFields)());
135
141
  })()),
136
142
  defaultMeta: { service: serviceName, release: process.env.APP_GIT_SHA },
137
143
  transports,
@@ -1,19 +1,30 @@
1
1
  import type { Span, Tracer } from "@opentelemetry/api";
2
2
  import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
3
+ import type { SpanProcessor } from "@opentelemetry/sdk-trace-node";
3
4
  export interface OtelConfig {
4
5
  serviceName: string;
5
6
  serviceVersion?: string;
6
7
  otlpEndpoint?: string;
7
8
  enabled?: boolean;
9
+ /**
10
+ * Replaces the OTLP exporter. Tests pass an in-memory processor so init
11
+ * never constructs a gRPC client. Production leaves this unset.
12
+ */
13
+ spanProcessors?: SpanProcessor[];
8
14
  }
9
15
  export declare function initTracing(config: OtelConfig): void;
10
16
  export declare function getTracer(): Tracer | null;
11
- export declare function shutdownTracing(): Promise<void>;
17
+ /**
18
+ * Flush and stop tracing. With `timeoutMs`, an unreachable collector cannot
19
+ * hold up process exit past that budget; the timeout rejects.
20
+ */
21
+ export declare function shutdownTracing(timeoutMs?: number): Promise<void>;
12
22
  export declare function flushTracing(): Promise<void>;
13
23
  export declare function createSpan(name: string, attributes?: Record<string, string | number | boolean>, kind?: SpanKind): Span | null;
14
24
  export declare function withSpan<T>(name: string, fn: (span: Span | null) => Promise<T>, attributes?: Record<string, string | number | boolean>): Promise<T>;
15
25
  export declare function getCurrentSpan(): Span | undefined;
16
- export declare function runInSpanContext<T>(span: Span, fn: () => T): T;
26
+ /** Run `fn` with `span` active, or plainly when tracing produced no span. */
27
+ export declare function runInSpanContext<T>(span: Span | null, fn: () => T): T;
17
28
  export declare function createRootSpan(name: string, attributes?: Record<string, string | number | boolean>): {
18
29
  span: Span | null;
19
30
  traceparent: string | null;