@tagma/sdk 0.7.3 → 0.7.4

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 (92) hide show
  1. package/README.md +26 -5
  2. package/dist/adapters/stdin-approval.d.ts +1 -5
  3. package/dist/adapters/stdin-approval.d.ts.map +1 -1
  4. package/dist/adapters/stdin-approval.js +1 -89
  5. package/dist/adapters/stdin-approval.js.map +1 -1
  6. package/dist/adapters/websocket-approval.d.ts +1 -27
  7. package/dist/adapters/websocket-approval.d.ts.map +1 -1
  8. package/dist/adapters/websocket-approval.js +1 -146
  9. package/dist/adapters/websocket-approval.js.map +1 -1
  10. package/dist/approval.d.ts +2 -12
  11. package/dist/approval.d.ts.map +1 -1
  12. package/dist/approval.js +1 -90
  13. package/dist/approval.js.map +1 -1
  14. package/dist/bootstrap.d.ts +1 -1
  15. package/dist/bootstrap.d.ts.map +1 -1
  16. package/dist/core/task-executor.d.ts.map +1 -1
  17. package/dist/core/task-executor.js +13 -4
  18. package/dist/core/task-executor.js.map +1 -1
  19. package/dist/engine.d.ts +5 -56
  20. package/dist/engine.d.ts.map +1 -1
  21. package/dist/engine.js +7 -297
  22. package/dist/engine.js.map +1 -1
  23. package/dist/index.d.ts +4 -6
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +2 -4
  26. package/dist/index.js.map +1 -1
  27. package/dist/logger.d.ts +2 -60
  28. package/dist/logger.d.ts.map +1 -1
  29. package/dist/logger.js +1 -153
  30. package/dist/logger.js.map +1 -1
  31. package/dist/plugins.d.ts +2 -2
  32. package/dist/plugins.d.ts.map +1 -1
  33. package/dist/plugins.js +1 -1
  34. package/dist/plugins.js.map +1 -1
  35. package/dist/registry.d.ts +2 -66
  36. package/dist/registry.d.ts.map +1 -1
  37. package/dist/registry.js +1 -292
  38. package/dist/registry.js.map +1 -1
  39. package/dist/runner.d.ts +1 -35
  40. package/dist/runner.d.ts.map +1 -1
  41. package/dist/runner.js +1 -610
  42. package/dist/runner.js.map +1 -1
  43. package/dist/runtime/adapters/stdin-approval.d.ts +2 -0
  44. package/dist/runtime/adapters/stdin-approval.d.ts.map +1 -0
  45. package/dist/runtime/adapters/stdin-approval.js +2 -0
  46. package/dist/runtime/adapters/stdin-approval.js.map +1 -0
  47. package/dist/runtime/adapters/websocket-approval.d.ts +2 -0
  48. package/dist/runtime/adapters/websocket-approval.d.ts.map +1 -0
  49. package/dist/runtime/adapters/websocket-approval.js +2 -0
  50. package/dist/runtime/adapters/websocket-approval.js.map +1 -0
  51. package/dist/runtime/bun-process-runner.d.ts +2 -0
  52. package/dist/runtime/bun-process-runner.d.ts.map +1 -0
  53. package/dist/runtime/bun-process-runner.js +2 -0
  54. package/dist/runtime/bun-process-runner.js.map +1 -0
  55. package/dist/runtime.d.ts +2 -8
  56. package/dist/runtime.d.ts.map +1 -1
  57. package/dist/runtime.js +1 -7
  58. package/dist/runtime.js.map +1 -1
  59. package/dist/tagma.d.ts +3 -4
  60. package/dist/tagma.d.ts.map +1 -1
  61. package/dist/tagma.js +2 -3
  62. package/dist/tagma.js.map +1 -1
  63. package/dist/triggers/file.d.ts.map +1 -1
  64. package/dist/triggers/file.js +74 -107
  65. package/dist/triggers/file.js.map +1 -1
  66. package/package.json +15 -4
  67. package/src/adapters/stdin-approval.ts +1 -106
  68. package/src/adapters/websocket-approval.ts +1 -224
  69. package/src/approval.ts +5 -127
  70. package/src/bootstrap.ts +1 -1
  71. package/src/core/run-context.test.ts +35 -0
  72. package/src/core/task-executor.ts +13 -4
  73. package/src/engine-ports-mixed.test.ts +70 -44
  74. package/src/engine-ports.test.ts +77 -33
  75. package/src/engine.ts +18 -444
  76. package/src/index.ts +4 -6
  77. package/src/logger.ts +2 -182
  78. package/src/package-split.test.ts +15 -0
  79. package/src/pipeline-runner.test.ts +65 -12
  80. package/src/plugin-registry.test.ts +69 -3
  81. package/src/plugins.ts +2 -2
  82. package/src/registry.ts +7 -353
  83. package/src/runner.ts +1 -666
  84. package/src/runtime/adapters/stdin-approval.ts +1 -0
  85. package/src/runtime/adapters/websocket-approval.ts +1 -0
  86. package/src/runtime/bun-process-runner.ts +1 -0
  87. package/src/runtime-adapters.test.ts +10 -0
  88. package/src/runtime.ts +12 -20
  89. package/src/tagma.test.ts +162 -0
  90. package/src/tagma.ts +9 -4
  91. package/src/triggers/file.test.ts +79 -0
  92. package/src/triggers/file.ts +85 -118
package/dist/logger.js CHANGED
@@ -1,154 +1,2 @@
1
- import { resolve, dirname } from 'node:path';
2
- import { mkdirSync, writeFileSync, openSync, writeSync, closeSync } from 'node:fs';
3
- const TASK_PREFIX_RE = /\[task:([^\]]+)\]/;
4
- function taskIdFromPrefix(prefix) {
5
- const m = TASK_PREFIX_RE.exec(prefix);
6
- return m ? m[1] : null;
7
- }
8
- /**
9
- * Dual-channel logger.
10
- *
11
- * - `info/warn/error` → console AND file (brief, user-visible events)
12
- * - `debug` → file ONLY (verbose diagnostics)
13
- * - `section` → file ONLY (visual separators)
14
- * - `quiet` → file ONLY (bulk payload like full stdout dumps)
15
- *
16
- * Log file path: <workDir>/.tagma/logs/<runId>/pipeline.log (one file per pipeline run,
17
- * truncated on construction). Every line is also forwarded to the optional
18
- * `onLine` callback as a structured `LogRecord`, so callers that want to
19
- * stream the run process over IPC/SSE don't need to tail the file.
20
- */
21
- export class Logger {
22
- filePath;
23
- runDir;
24
- onLine;
25
- /** Persistent file descriptor for append writes (avoids open/close per line). */
26
- fd;
27
- constructor(workDir, runId, onLine) {
28
- this.runDir = resolve(workDir, '.tagma', 'logs', runId);
29
- this.filePath = resolve(this.runDir, 'pipeline.log');
30
- this.onLine = onLine ?? null;
31
- mkdirSync(dirname(this.filePath), { recursive: true });
32
- const header = `# Pipeline run ${runId} @ ${new Date().toISOString()}\n` +
33
- `# Host: ${process.platform} ${process.arch} Bun: ${process.versions.bun ?? 'n/a'}\n` +
34
- `# Work dir: ${workDir}\n\n`;
35
- writeFileSync(this.filePath, header);
36
- // Open once for all subsequent appends (O_APPEND is implied by 'a' flag)
37
- this.fd = openSync(this.filePath, 'a');
38
- }
39
- info(prefix, message) {
40
- const ts = timestamp();
41
- const line = `${ts} ${prefix} ${message}`;
42
- // eslint-disable-next-line no-console
43
- console.log(line);
44
- this.emit('info', ts, line, taskIdFromPrefix(prefix));
45
- this.append(line);
46
- }
47
- warn(prefix, message) {
48
- const ts = timestamp();
49
- const line = `${ts} ${prefix} WARN: ${message}`;
50
- console.warn(line);
51
- this.emit('warn', ts, line, taskIdFromPrefix(prefix));
52
- this.append(line);
53
- }
54
- error(prefix, message) {
55
- const ts = timestamp();
56
- const line = `${ts} ${prefix} ERROR: ${message}`;
57
- console.error(line);
58
- this.emit('error', ts, line, taskIdFromPrefix(prefix));
59
- this.append(line);
60
- }
61
- /** File-only diagnostic log line. */
62
- debug(prefix, message) {
63
- const ts = timestamp();
64
- const line = `${ts} ${prefix} DEBUG: ${message}`;
65
- this.emit('debug', ts, line, taskIdFromPrefix(prefix));
66
- this.append(line);
67
- }
68
- /** File-only visual separator with title. */
69
- section(title, taskId) {
70
- const ts = timestamp();
71
- const text = `\n━━━ ${title} ━━━`;
72
- this.emit('section', ts, text, taskId ?? null);
73
- this.append(text);
74
- }
75
- /** File-only bulk payload (e.g. full stdout / stderr dumps). */
76
- quiet(message, taskId) {
77
- const ts = timestamp();
78
- this.emit('quiet', ts, message, taskId ?? null);
79
- this.append(message);
80
- }
81
- append(line) {
82
- if (this.fd === null)
83
- return;
84
- try {
85
- const data = line.endsWith('\n') ? line : line + '\n';
86
- writeSync(this.fd, data);
87
- }
88
- catch {
89
- // Swallow log write failures; engine correctness shouldn't depend on logging.
90
- }
91
- }
92
- /** Close the persistent file handle. Called by the engine at run completion. */
93
- close() {
94
- if (this.fd !== null) {
95
- try {
96
- closeSync(this.fd);
97
- }
98
- catch {
99
- /* already closed */
100
- }
101
- this.fd = null;
102
- }
103
- }
104
- emit(level, ts, text, taskId) {
105
- if (!this.onLine)
106
- return;
107
- try {
108
- this.onLine({ level, taskId, timestamp: ts, text });
109
- }
110
- catch {
111
- // Never let a listener error derail the pipeline.
112
- }
113
- }
114
- get path() {
115
- return this.filePath;
116
- }
117
- /** Directory that holds all artifacts for this run (pipeline.log, *.stderr, etc.). */
118
- get dir() {
119
- return this.runDir;
120
- }
121
- }
122
- function timestamp() {
123
- const d = new Date();
124
- const hh = String(d.getHours()).padStart(2, '0');
125
- const mm = String(d.getMinutes()).padStart(2, '0');
126
- const ss = String(d.getSeconds()).padStart(2, '0');
127
- const ms = String(d.getMilliseconds()).padStart(3, '0');
128
- return `${hh}:${mm}:${ss}.${ms}`;
129
- }
130
- /** Return the last `n` non-empty lines of `text`, joined with newlines. */
131
- export function tailLines(text, n) {
132
- if (!text)
133
- return '';
134
- const lines = text.split(/\r?\n/).filter((l) => l.length > 0);
135
- return lines.slice(-n).join('\n');
136
- }
137
- /**
138
- * Truncate a blob to at most `maxBytes` UTF-8 bytes for log embedding,
139
- * appending a marker when truncation occurred.
140
- * Uses TextEncoder so CJK and emoji (multi-byte) characters are counted correctly.
141
- */
142
- export function clip(text, maxBytes = 16 * 1024) {
143
- if (!text)
144
- return '';
145
- const encoder = new TextEncoder();
146
- const bytes = encoder.encode(text);
147
- if (bytes.length <= maxBytes)
148
- return text;
149
- const omittedBytes = bytes.length - maxBytes;
150
- // TextDecoder handles partial code-point boundaries safely (replacement char insertion)
151
- const truncated = new TextDecoder().decode(bytes.slice(0, maxBytes));
152
- return truncated + `\n…[truncated ${omittedBytes} bytes]`;
153
- }
1
+ export { clip, Logger, tailLines } from '@tagma/core';
154
2
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAoBnF,MA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;IACrB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,QAAQ,GAAG,EAAE,GAAG,IAAI;IACrD,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1C,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC;IAC7C,wFAAwF;IACxF,MAAM,SAAS,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IACrE,OAAO,SAAS,GAAG,iBAAiB,YAAY,SAAS,CAAC;AAC5D,CAAC"}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
package/dist/plugins.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { bootstrapBuiltins } from './bootstrap';
2
- export { PluginRegistry, isValidPluginName, PLUGIN_NAME_RE, readPluginManifest, } from './registry';
3
- export type { RegisteredCapability, RegisterResult } from './registry';
2
+ export { PluginRegistry, isValidPluginName, PLUGIN_NAME_RE, readPluginManifest, } from '@tagma/core';
3
+ export type { RegisteredCapability, RegisterResult } from '@tagma/core';
4
4
  export type { CapabilityHandler, PluginCategory, PluginCapabilities, PluginModule, PluginManifest, PluginSetupContext, TagmaPlugin, DriverPlugin, TriggerPlugin, CompletionPlugin, MiddlewarePlugin, } from './types';
5
5
  //# sourceMappingURL=plugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvE,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxE,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
package/dist/plugins.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { bootstrapBuiltins } from './bootstrap';
2
- export { PluginRegistry, isValidPluginName, PLUGIN_NAME_RE, readPluginManifest, } from './registry';
2
+ export { PluginRegistry, isValidPluginName, PLUGIN_NAME_RE, readPluginManifest, } from '@tagma/core';
3
3
  //# sourceMappingURL=plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC"}
@@ -1,67 +1,3 @@
1
- import type { CapabilityHandler, PluginCategory, PluginManifest, TagmaPlugin } from './types';
2
- type PluginType = CapabilityHandler;
3
- export interface RegisteredCapability {
4
- readonly category: PluginCategory;
5
- readonly type: string;
6
- readonly result: RegisterResult;
7
- }
8
- export type RegisterResult = 'registered' | 'replaced' | 'unchanged';
9
- export declare const PLUGIN_NAME_RE: RegExp;
10
- export declare function isValidPluginName(name: unknown): name is string;
11
- /**
12
- * Parse and validate the `tagmaPlugin` field of a `package.json` blob.
13
- *
14
- * Returns the strongly-typed manifest if the field is present and
15
- * well-formed (`category` is one of the four known categories and `type`
16
- * is a non-empty string). Returns `null` if the field is absent —that
17
- * is the host's signal that the package is a library, not a plugin.
18
- *
19
- * Throws if the field is present but malformed: that's a packaging bug
20
- * the plugin author should hear about loudly, not a silent skip.
21
- *
22
- * Hosts use this during auto-discovery to decide whether to load a
23
- * package as a plugin without having to dynamically `import()` it.
24
- */
25
- export declare function readPluginManifest(pkgJson: unknown): PluginManifest | null;
26
- /**
27
- * Instance-scoped plugin registry. Each workspace in a multi-tenant sidecar
28
- * owns its own PluginRegistry, so installing/uninstalling a driver in one
29
- * workspace cannot clobber another.
30
- */
31
- export declare class PluginRegistry {
32
- private readonly registries;
33
- /**
34
- * Register a plugin under (category, type). Returns:
35
- * - 'registered' on first registration
36
- * - 'replaced' when an existing entry was overwritten with a different handler
37
- * - 'unchanged' when the same handler instance was already present
38
- *
39
- * Throws if `category` is unknown, `type` is empty, or `handler` violates
40
- * the minimum interface contract for the category.
41
- */
42
- registerPlugin<T extends PluginType>(category: PluginCategory, type: string, handler: T): RegisterResult;
43
- registerTagmaPlugin(plugin: TagmaPlugin): RegisteredCapability[];
44
- /**
45
- * Remove a plugin from the in-process registry. Returns true if a plugin
46
- * was actually removed. Note: ESM module caching is not affected, so
47
- * re-importing the same file after unregister will yield the cached module — * callers wanting a fresh load must restart the host process.
48
- */
49
- unregisterPlugin(category: PluginCategory, type: string): boolean;
50
- getHandler<T extends PluginType>(category: PluginCategory, type: string): T;
51
- hasHandler(category: PluginCategory, type: string): boolean;
52
- listRegistered(category: PluginCategory): string[];
53
- /**
54
- * Load and register a list of plugin packages into this registry.
55
- *
56
- * @param pluginNames - Validated npm package names to load.
57
- * @param resolveFrom - Optional absolute path to resolve plugins from (e.g.
58
- * the workspace's working directory). When omitted, the default ESM
59
- * resolution uses the SDK's own `node_modules`, which will fail for
60
- * plugins installed only in the user's workspace. CLI callers should
61
- * pass `process.cwd()` or the workspace root so that workspace-local
62
- * plugins resolve correctly.
63
- */
64
- loadPlugins(pluginNames: readonly string[], resolveFrom?: string): Promise<void>;
65
- }
66
- export {};
1
+ export { isValidPluginName, PluginRegistry, PLUGIN_NAME_RE, readPluginManifest, } from '@tagma/core';
2
+ export type { RegisteredCapability, RegisterResult } from '@tagma/core';
67
3
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EAKd,cAAc,EACd,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,KAAK,UA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"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
package/dist/registry.js CHANGED
@@ -1,293 +1,2 @@
1
- import { createRequire } from 'node:module';
2
- import { pathToFileURL } from 'node:url';
3
- const CAPABILITY_CATEGORIES = [
4
- 'drivers',
5
- 'triggers',
6
- 'completions',
7
- 'middlewares',
8
- ];
9
- const VALID_CATEGORIES = new Set(CAPABILITY_CATEGORIES);
10
- const PLUGIN_TYPE_RE = /^[A-Za-z_][A-Za-z0-9_-]*$/;
11
- function singularCategory(category) {
12
- switch (category) {
13
- case 'drivers':
14
- return 'driver';
15
- case 'triggers':
16
- return 'trigger';
17
- case 'completions':
18
- return 'completion';
19
- case 'middlewares':
20
- return 'middleware';
21
- }
22
- }
23
- /**
24
- * Minimal contract enforcement so a malformed plugin fails fast at
25
- * registration time rather than crashing the engine mid-run.
26
- *
27
- * For drivers we materialize `capabilities` and assert each field is a
28
- * boolean —otherwise a plugin author can write
29
- * get capabilities() { throw new Error('boom') }
30
- * and pass the basic typeof check, then crash preflight when the engine
31
- * touches `driver.capabilities.sessionResume`. (R8)
32
- */
33
- function validateContract(category, handler) {
34
- if (!handler || typeof handler !== 'object') {
35
- throw new Error(`Plugin handler for category "${category}" must be an object`);
36
- }
37
- const h = handler;
38
- if (typeof h.name !== 'string' || h.name.length === 0) {
39
- throw new Error(`Plugin handler for category "${category}" must declare a non-empty "name"`);
40
- }
41
- switch (category) {
42
- case 'drivers': {
43
- if (typeof h.buildCommand !== 'function') {
44
- throw new Error(`drivers plugin "${h.name}" must export buildCommand()`);
45
- }
46
- // Materialize capabilities —this triggers any throwing getter NOW
47
- // instead of during preflight.
48
- let caps;
49
- try {
50
- caps = h.capabilities;
51
- }
52
- catch (err) {
53
- throw new Error(`drivers plugin "${h.name}" capabilities accessor threw: ` +
54
- (err instanceof Error ? err.message : String(err)));
55
- }
56
- if (!caps || typeof caps !== 'object') {
57
- throw new Error(`drivers plugin "${h.name}" must declare capabilities object`);
58
- }
59
- const c = caps;
60
- for (const field of ['sessionResume', 'systemPrompt', 'outputFormat']) {
61
- if (typeof c[field] !== 'boolean') {
62
- throw new Error(`drivers plugin "${h.name}".capabilities.${field} must be a boolean (got ${typeof c[field]})`);
63
- }
64
- }
65
- // Optional methods, but if present must be functions.
66
- for (const opt of ['parseResult', 'resolveModel', 'resolveTools']) {
67
- if (h[opt] !== undefined && typeof h[opt] !== 'function') {
68
- throw new Error(`drivers plugin "${h.name}".${opt} must be a function or undefined`);
69
- }
70
- }
71
- break;
72
- }
73
- case 'triggers':
74
- if (typeof h.watch !== 'function') {
75
- throw new Error(`triggers plugin "${h.name}" must export watch()`);
76
- }
77
- break;
78
- case 'completions':
79
- if (typeof h.check !== 'function') {
80
- throw new Error(`completions plugin "${h.name}" must export check()`);
81
- }
82
- break;
83
- case 'middlewares':
84
- if (typeof h.enhanceDoc !== 'function') {
85
- throw new Error(`middlewares plugin "${h.name}" must export enhanceDoc()`);
86
- }
87
- break;
88
- }
89
- }
90
- // Plugin name must be a scoped npm package or a tagma-prefixed package.
91
- // Reject absolute/relative paths and suspicious patterns to prevent
92
- // arbitrary code execution via crafted YAML configs.
93
- export const PLUGIN_NAME_RE = /^(@[a-z0-9-]+\/[a-z0-9._-]+|tagma-plugin-[a-z0-9._-]+)$/;
94
- export function isValidPluginName(name) {
95
- return typeof name === 'string' && PLUGIN_NAME_RE.test(name);
96
- }
97
- /**
98
- * Parse and validate the `tagmaPlugin` field of a `package.json` blob.
99
- *
100
- * Returns the strongly-typed manifest if the field is present and
101
- * well-formed (`category` is one of the four known categories and `type`
102
- * is a non-empty string). Returns `null` if the field is absent —that
103
- * is the host's signal that the package is a library, not a plugin.
104
- *
105
- * Throws if the field is present but malformed: that's a packaging bug
106
- * the plugin author should hear about loudly, not a silent skip.
107
- *
108
- * Hosts use this during auto-discovery to decide whether to load a
109
- * package as a plugin without having to dynamically `import()` it.
110
- */
111
- export function readPluginManifest(pkgJson) {
112
- if (!pkgJson || typeof pkgJson !== 'object')
113
- return null;
114
- const raw = pkgJson.tagmaPlugin;
115
- if (raw === undefined)
116
- return null;
117
- if (!raw || typeof raw !== 'object') {
118
- throw new Error('tagmaPlugin field must be an object with { category, type }');
119
- }
120
- const m = raw;
121
- const category = m.category;
122
- const type = m.type;
123
- if (typeof category !== 'string' || !VALID_CATEGORIES.has(category)) {
124
- throw new Error(`tagmaPlugin.category must be one of ${[...VALID_CATEGORIES].join(', ')}, got ${JSON.stringify(category)}`);
125
- }
126
- if (typeof type !== 'string' || type.length === 0) {
127
- throw new Error(`tagmaPlugin.type must be a non-empty string, got ${JSON.stringify(type)}`);
128
- }
129
- if (!PLUGIN_TYPE_RE.test(type)) {
130
- throw new Error(`tagmaPlugin.type must match ${PLUGIN_TYPE_RE} (letters, digits, underscores, hyphens; no paths or dots), got ${JSON.stringify(type)}`);
131
- }
132
- return { category: category, type };
133
- }
134
- function isRecord(value) {
135
- return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
136
- }
137
- function isTagmaPlugin(value) {
138
- if (!isRecord(value))
139
- return false;
140
- if (typeof value.name !== 'string' || value.name.length === 0)
141
- return false;
142
- if (value.capabilities !== undefined && !isRecord(value.capabilities))
143
- return false;
144
- if (value.setup !== undefined && typeof value.setup !== 'function')
145
- return false;
146
- return true;
147
- }
148
- function hasSupportedCapabilityMap(plugin) {
149
- if (!plugin.capabilities)
150
- return false;
151
- const capabilities = plugin.capabilities;
152
- return CAPABILITY_CATEGORIES.some((category) => capabilities[category] !== undefined);
153
- }
154
- function moduleDefaultPlugin(name, mod) {
155
- if (!isRecord(mod) || !isTagmaPlugin(mod.default) || !hasSupportedCapabilityMap(mod.default)) {
156
- throw new Error(`Plugin "${name}" must default-export a TagmaPlugin with capabilities maps`);
157
- }
158
- return mod.default;
159
- }
160
- /**
161
- * Instance-scoped plugin registry. Each workspace in a multi-tenant sidecar
162
- * owns its own PluginRegistry, so installing/uninstalling a driver in one
163
- * workspace cannot clobber another.
164
- */
165
- export class PluginRegistry {
166
- registries = {
167
- drivers: new Map(),
168
- triggers: new Map(),
169
- completions: new Map(),
170
- middlewares: new Map(),
171
- };
172
- /**
173
- * Register a plugin under (category, type). Returns:
174
- * - 'registered' on first registration
175
- * - 'replaced' when an existing entry was overwritten with a different handler
176
- * - 'unchanged' when the same handler instance was already present
177
- *
178
- * Throws if `category` is unknown, `type` is empty, or `handler` violates
179
- * the minimum interface contract for the category.
180
- */
181
- registerPlugin(category, type, handler) {
182
- if (!VALID_CATEGORIES.has(category)) {
183
- throw new Error(`Unknown plugin category "${category}"`);
184
- }
185
- if (typeof type !== 'string' || type.length === 0) {
186
- throw new Error(`Plugin type must be a non-empty string (category="${category}")`);
187
- }
188
- if (!PLUGIN_TYPE_RE.test(type)) {
189
- throw new Error(`Plugin type "${type}" must match ${PLUGIN_TYPE_RE} (letters, digits, underscores, hyphens; no paths or dots)`);
190
- }
191
- validateContract(category, handler);
192
- const registry = this.registries[category];
193
- const existing = registry.get(type);
194
- if (existing === handler)
195
- return 'unchanged';
196
- const wasReplaced = existing !== undefined;
197
- registry.set(type, handler);
198
- if (wasReplaced) {
199
- // D18: surface silent shadowing. Hot-reload flows legitimately replace
200
- // handlers; installing two different plugin packages that both claim
201
- // the same (category, type) does not —the second wins and breaks the
202
- // first's consumers with no audit trail. A console.warn is cheap,
203
- // respects existing callers that rely on 'replaced', and gives ops a
204
- // grep-able signal when registrations collide unexpectedly.
205
- console.warn(`[tagma-sdk] registerPlugin: replaced existing ${category}/${type} - ` +
206
- `check for duplicate plugin packages claiming the same type.`);
207
- }
208
- return wasReplaced ? 'replaced' : 'registered';
209
- }
210
- registerTagmaPlugin(plugin) {
211
- if (!isTagmaPlugin(plugin)) {
212
- throw new Error('TagmaPlugin must be an object with a non-empty "name"');
213
- }
214
- if (!plugin.capabilities) {
215
- throw new Error(`TagmaPlugin "${plugin.name}" must declare capabilities`);
216
- }
217
- const registered = [];
218
- const capabilities = plugin.capabilities;
219
- for (const category of CAPABILITY_CATEGORIES) {
220
- const handlers = capabilities[category];
221
- if (handlers === undefined)
222
- continue;
223
- if (!isRecord(handlers)) {
224
- throw new Error(`TagmaPlugin "${plugin.name}" capabilities.${category} must be an object map`);
225
- }
226
- for (const [type, handler] of Object.entries(handlers)) {
227
- const result = this.registerPlugin(category, type, handler);
228
- registered.push({ category, type, result });
229
- }
230
- }
231
- if (registered.length === 0) {
232
- throw new Error(`TagmaPlugin "${plugin.name}" must declare at least one supported capability`);
233
- }
234
- return registered;
235
- }
236
- /**
237
- * Remove a plugin from the in-process registry. Returns true if a plugin
238
- * was actually removed. Note: ESM module caching is not affected, so
239
- * re-importing the same file after unregister will yield the cached module — * callers wanting a fresh load must restart the host process.
240
- */
241
- unregisterPlugin(category, type) {
242
- if (!VALID_CATEGORIES.has(category))
243
- return false;
244
- return this.registries[category].delete(type);
245
- }
246
- getHandler(category, type) {
247
- const handler = this.registries[category].get(type);
248
- if (!handler) {
249
- throw new Error(`${category} type "${type}" not registered.\n` +
250
- `Install the plugin: bun add @tagma/${singularCategory(category)}-${type}`);
251
- }
252
- return handler;
253
- }
254
- hasHandler(category, type) {
255
- return this.registries[category].has(type);
256
- }
257
- listRegistered(category) {
258
- return [...this.registries[category].keys()];
259
- }
260
- /**
261
- * Load and register a list of plugin packages into this registry.
262
- *
263
- * @param pluginNames - Validated npm package names to load.
264
- * @param resolveFrom - Optional absolute path to resolve plugins from (e.g.
265
- * the workspace's working directory). When omitted, the default ESM
266
- * resolution uses the SDK's own `node_modules`, which will fail for
267
- * plugins installed only in the user's workspace. CLI callers should
268
- * pass `process.cwd()` or the workspace root so that workspace-local
269
- * plugins resolve correctly.
270
- */
271
- async loadPlugins(pluginNames, resolveFrom) {
272
- for (const name of pluginNames) {
273
- if (!isValidPluginName(name)) {
274
- throw new Error(`Plugin "${name}" rejected: plugin names must be scoped npm packages ` +
275
- `(e.g. @tagma/trigger-xyz) or tagma-plugin-* packages. ` +
276
- `Relative/absolute paths are not allowed.`);
277
- }
278
- let moduleUrl = name;
279
- if (resolveFrom) {
280
- // Resolve the package entry point relative to the caller's directory
281
- // so plugins installed in the workspace's node_modules are found
282
- // even when the SDK itself lives elsewhere (e.g. a global install
283
- // or a monorepo sibling package).
284
- const req = createRequire(resolveFrom.endsWith('/') ? resolveFrom : resolveFrom + '/');
285
- const resolved = req.resolve(name);
286
- moduleUrl = pathToFileURL(resolved).href;
287
- }
288
- const mod = await import(moduleUrl);
289
- this.registerTagmaPlugin(moduleDefaultPlugin(name, mod));
290
- }
291
- }
292
- }
1
+ export { isValidPluginName, PluginRegistry, PLUGIN_NAME_RE, readPluginManifest, } from '@tagma/core';
293
2
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAczC,MAAM,qBAAqB,GAAG;IAC5B,SAAS;IACT,UAAU;IACV,aAAa;IACb,aAAa;CAC+B,CAAC;AAE/C,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAAC,qBAAqB,CAAC,CAAC;AACrF,MAAM,cAAc,GAAG,2BAA2B,CAAC;AAQnD,SAAS,gBAAgB,CAAC,QAAwB;IAChD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,SAAS;YACZ,OAAO,QAAQ,CAAC;QAClB,KAAK,UAAU;YACb,OAAO,SAAS,CAAC;QACnB,KAAK,aAAa;YAChB,OAAO,YAAY,CAAC;QACtB,KAAK,aAAa;YAChB,OAAO,YAAY,CAAC;IACxB,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CAAC,QAAwB,EAAE,O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,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACb,WAAW,IAAI,uDAAuD;oBACpE,wDAAwD;oBACxD,0CAA0C,CAC7C,CAAC;YACJ,CAAC;YACD,IAAI,SAAS,GAAW,IAAI,CAAC;YAC7B,IAAI,WAAW,EAAE,CAAC;gBAChB,qEAAqE;gBACrE,iEAAiE;gBACjE,kEAAkE;gBAClE,kCAAkC;gBAClC,MAAM,GAAG,GAAG,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC;gBACvF,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACnC,SAAS,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;YAC3C,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;YACpC,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC"}
package/dist/runner.d.ts CHANGED
@@ -1,36 +1,2 @@
1
- import type { SpawnSpec, DriverPlugin, TaskResult } from './types';
2
- export interface RunOptions {
3
- readonly timeoutMs?: number;
4
- readonly signal?: AbortSignal;
5
- /**
6
- * If set, stream the child's stdout to this file path as it arrives. The
7
- * returned `TaskResult.stdout` is still a bounded in-memory tail
8
- * (`maxStdoutTailBytes`) — callers that need the full output should read
9
- * from the returned `stdoutPath`. Parent directories are created as needed.
10
- */
11
- readonly stdoutPath?: string;
12
- /** Symmetric to `stdoutPath` for stderr. */
13
- readonly stderrPath?: string;
14
- /**
15
- * Cap on bytes retained in memory for the returned `TaskResult.stdout`
16
- * string. Defaults to `DEFAULT_STDOUT_TAIL_BYTES`. Bytes beyond this cap
17
- * from the HEAD of the stream are dropped from the in-memory string; the
18
- * on-disk file (if `stdoutPath` is set) is still the full output.
19
- */
20
- readonly maxStdoutTailBytes?: number;
21
- readonly maxStderrTailBytes?: number;
22
- }
23
- /**
24
- * R2: Validate a SpawnSpec returned by a third-party driver. Returns null on
25
- * success or a human-readable error message describing the first violation.
26
- *
27
- * Catching this here is critical: an undetected bad spec ends up calling
28
- * Bun.spawn with garbage and the resulting TypeError leaks into engine
29
- * processTask's catch block as "Cannot read properties of undefined". By
30
- * validating here we surface a clear "Driver X returned invalid args" message
31
- * instead, and short-circuit before holding any process resources.
32
- */
33
- export declare function validateSpawnSpec(spec: unknown, driverName: string): string | null;
34
- export declare function runSpawn(spec: SpawnSpec, driver: DriverPlugin | null, opts?: RunOptions): Promise<TaskResult>;
35
- export declare function runCommand(command: string, cwd: string, opts?: RunOptions): Promise<TaskResult>;
1
+ export { runCommand, runSpawn } from '@tagma/runtime-bun';
36
2
  //# sourceMappingURL=runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA4CnE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AA4SD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoClF;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,UAAU,CAAC,CA0OrB;AAED,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,UAAU,CAAC,CAMrB"}
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC"}