@cat-factory/orchestration 0.76.0 → 0.78.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.
@@ -0,0 +1,64 @@
1
+ import { DEFAULT_WORKSPACE_SETTINGS } from '@cat-factory/kernel';
2
+ /**
3
+ * Defensive upper bound (characters) on a stored query. Real search queries sit far
4
+ * below this; the cap exists only so a pathological query can't blow past the store's
5
+ * per-value limit and make the whole row fail to record.
6
+ */
7
+ export const MAX_SEARCH_QUERY_CHARS = 8 * 1024;
8
+ function clamp(text) {
9
+ if (text.length <= MAX_SEARCH_QUERY_CHARS)
10
+ return text;
11
+ return `${text.slice(0, MAX_SEARCH_QUERY_CHARS)}…`;
12
+ }
13
+ /**
14
+ * The agent-search-query observability sink. The container web-search proxy
15
+ * (`webSearchProxyController`) calls {@link record} best-effort after each search the
16
+ * agent performs. A sibling of the {@link AgentContextObservabilityService}: that keeps
17
+ * the complete context the agent was provided, this keeps the searches the agent ran.
18
+ *
19
+ * Storing is gated twice: the deployment-wide prompt-recording switch
20
+ * ({@link recordPrompts}) AND the per-workspace `storeAgentContext` setting must both be
21
+ * enabled. Wired only when a search-query repository is present, so tests and
22
+ * unconfigured facades collect nothing.
23
+ */
24
+ export class SearchQueryObservabilityService {
25
+ repository;
26
+ settings;
27
+ idGenerator;
28
+ clock;
29
+ recordPrompts;
30
+ constructor({ agentSearchQueryRepository, workspaceSettingsRepository, idGenerator, clock, recordPrompts = true, }) {
31
+ this.repository = agentSearchQueryRepository;
32
+ this.settings = workspaceSettingsRepository;
33
+ this.idGenerator = idGenerator;
34
+ this.clock = clock;
35
+ this.recordPrompts = recordPrompts;
36
+ }
37
+ /**
38
+ * Persist one performed search query, assigning its id + timestamp. Returns without
39
+ * storing when prompt recording is disabled deployment-wide or the workspace has
40
+ * turned `storeAgentContext` off.
41
+ */
42
+ async record(input) {
43
+ if (!this.recordPrompts)
44
+ return;
45
+ if (!(await this.storeEnabled(input.workspaceId)))
46
+ return;
47
+ const query = {
48
+ ...input,
49
+ query: clamp(input.query),
50
+ id: this.idGenerator.next('asq'),
51
+ createdAt: this.clock.now(),
52
+ };
53
+ await this.repository.record(query);
54
+ }
55
+ /** Queries recorded for a run, newest first (for the observability drill-down). */
56
+ listByExecution(workspaceId, executionId) {
57
+ return this.repository.listByExecution(workspaceId, executionId);
58
+ }
59
+ async storeEnabled(workspaceId) {
60
+ const settings = (await this.settings.get(workspaceId)) ?? DEFAULT_WORKSPACE_SETTINGS;
61
+ return settings.storeAgentContext;
62
+ }
63
+ }
64
+ //# sourceMappingURL=SearchQueryObservabilityService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchQueryObservabilityService.js","sourceRoot":"","sources":["../../../src/modules/observability/SearchQueryObservabilityService.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAEhE;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAG,IAAI,CAAA;AAE9C,SAAS,KAAK,CAAC,IAAY;IACzB,IAAI,IAAI,CAAC,MAAM,IAAI,sBAAsB;QAAE,OAAO,IAAI,CAAA;IACtD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,sBAAsB,CAAC,GAAG,CAAA;AACpD,CAAC;AAgBD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,+BAA+B;IACzB,UAAU,CAA4B;IACtC,QAAQ,CAA6B;IACrC,WAAW,CAAa;IACxB,KAAK,CAAO;IACZ,aAAa,CAAS;IAEvC,YAAY,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,WAAW,EACX,KAAK,EACL,aAAa,GAAG,IAAI,GACwB;QAC5C,IAAI,CAAC,UAAU,GAAG,0BAA0B,CAAA;QAC5C,IAAI,CAAC,QAAQ,GAAG,2BAA2B,CAAA;QAC3C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,KAAkC;QAC7C,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,OAAM;QAC/B,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAAE,OAAM;QACzD,MAAM,KAAK,GAAqB;YAC9B,GAAG,KAAK;YACR,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;YACzB,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;YAChC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;SAC5B,CAAA;QACD,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACrC,CAAC;IAED,mFAAmF;IACnF,eAAe,CAAC,WAAmB,EAAE,WAAmB;QACtD,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;IAClE,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,WAAmB;QAC5C,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,0BAA0B,CAAA;QACrF,OAAO,QAAQ,CAAC,iBAAiB,CAAA;IACnC,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cat-factory/orchestration",
3
- "version": "0.76.0",
3
+ "version": "0.78.0",
4
4
  "description": "Delivery-workflow engine for the Agent Architecture Board (execution, bootstrap, pipelines, board, boardScan, requirements, and composition root).",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,20 +25,20 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "ai": "^6.0.219",
28
- "@cat-factory/agents": "0.39.1",
29
- "@cat-factory/caching": "0.4.11",
30
- "@cat-factory/contracts": "0.103.0",
31
- "@cat-factory/integrations": "0.70.0",
32
- "@cat-factory/kernel": "0.94.0",
33
- "@cat-factory/prompt-fragments": "0.10.9",
34
- "@cat-factory/sandbox": "0.9.10",
35
- "@cat-factory/spend": "0.10.103",
36
- "@cat-factory/workspaces": "0.11.21"
28
+ "@cat-factory/agents": "0.39.3",
29
+ "@cat-factory/caching": "0.4.13",
30
+ "@cat-factory/contracts": "0.105.0",
31
+ "@cat-factory/integrations": "0.71.0",
32
+ "@cat-factory/kernel": "0.96.0",
33
+ "@cat-factory/prompt-fragments": "0.10.11",
34
+ "@cat-factory/sandbox": "0.9.12",
35
+ "@cat-factory/spend": "0.10.105",
36
+ "@cat-factory/workspaces": "0.11.23"
37
37
  },
38
38
  "devDependencies": {
39
39
  "typescript": "7.0.1-rc",
40
40
  "vitest": "^4.1.9",
41
- "@cat-factory/sandbox-fixtures": "0.7.117"
41
+ "@cat-factory/sandbox-fixtures": "0.7.119"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsc -b tsconfig.build.json",