@wrongstack/runtime 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ECOSTACK TECHNOLOGY OÜ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @wrongstack/runtime
2
+
3
+ Default runtime implementations and host composition types for WrongStack.
4
+
5
+ `@wrongstack/core` should stay focused on the agent kernel, public contracts,
6
+ registries, and lifecycle primitives. This package is the migration target for
7
+ concrete defaults such as storage, config, permissions, metrics, compaction,
8
+ models, skills, and host-level assembly helpers.
9
+
10
+ In the first refactor slice, runtime re-exports the existing default
11
+ implementations from `@wrongstack/core/defaults`. That lets CLI, TUI, WebUI,
12
+ and future hosts start importing defaults from `@wrongstack/runtime` while the
13
+ physical module moves happen incrementally.
14
+
15
+ ```ts
16
+ import { DefaultSessionStore, DefaultPermissionPolicy } from '@wrongstack/runtime';
17
+ import { Agent, Container, EventBus } from '@wrongstack/core';
18
+ ```
19
+
20
+ The `WrongStackPack` interface in `@wrongstack/runtime/pack` is the target shape
21
+ for extension packages that contribute tools, providers, slash commands, or
22
+ agent lifecycle extensions.
package/dist/host.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ import '@wrongstack/core/defaults';
2
+ import '@wrongstack/core/infrastructure';
3
+ import { PluginAPI, Agent, Context, EventBus, ToolRegistry, ProviderRegistry, SlashCommandRegistry, SessionWriter, ExtensionRegistry } from '@wrongstack/core';
4
+ import { WrongStackPack } from './pack.js';
5
+
6
+ interface RuntimeHost {
7
+ agent: Agent;
8
+ context: Context;
9
+ events: EventBus;
10
+ tools: ToolRegistry;
11
+ providers: ProviderRegistry;
12
+ slashCommands: SlashCommandRegistry;
13
+ session: SessionWriter;
14
+ extensions?: ExtensionRegistry;
15
+ shutdown(): Promise<void>;
16
+ }
17
+ interface RuntimeHostParts {
18
+ agent: Agent;
19
+ context: Context;
20
+ events: EventBus;
21
+ tools: ToolRegistry;
22
+ providers: ProviderRegistry;
23
+ slashCommands: SlashCommandRegistry;
24
+ session: SessionWriter;
25
+ extensions?: ExtensionRegistry;
26
+ shutdown?: () => void | Promise<void>;
27
+ }
28
+ declare function createRuntimeHostFromParts(parts: RuntimeHostParts): RuntimeHost;
29
+ interface ApplyPackOptions {
30
+ owner?: string;
31
+ api?: PluginAPI;
32
+ }
33
+ interface AppliedPack {
34
+ pack: WrongStackPack;
35
+ owner: string;
36
+ teardown(): Promise<void>;
37
+ }
38
+ declare function applyWrongStackPack(host: Pick<RuntimeHost, 'tools' | 'providers' | 'slashCommands'> & {
39
+ extensions?: ExtensionRegistry;
40
+ }, pack: WrongStackPack, opts?: ApplyPackOptions): Promise<AppliedPack>;
41
+ declare function applyWrongStackPacks(host: Pick<RuntimeHost, 'tools' | 'providers' | 'slashCommands'> & {
42
+ extensions?: ExtensionRegistry;
43
+ }, packs: readonly WrongStackPack[], opts?: ApplyPackOptions): Promise<AppliedPack[]>;
44
+
45
+ export { type AppliedPack, type ApplyPackOptions, type RuntimeHost, type RuntimeHostParts, applyWrongStackPack, applyWrongStackPacks, createRuntimeHostFromParts };
package/dist/host.js ADDED
@@ -0,0 +1,73 @@
1
+ // src/host.ts
2
+ function createRuntimeHostFromParts(parts) {
3
+ return {
4
+ agent: parts.agent,
5
+ context: parts.context,
6
+ events: parts.events,
7
+ tools: parts.tools,
8
+ providers: parts.providers,
9
+ slashCommands: parts.slashCommands,
10
+ session: parts.session,
11
+ extensions: parts.extensions,
12
+ async shutdown() {
13
+ await parts.shutdown?.();
14
+ }
15
+ };
16
+ }
17
+ async function applyWrongStackPack(host, pack, opts = {}) {
18
+ const owner = opts.owner ?? pack.name;
19
+ const unregisterExtensions = [];
20
+ if (pack.tools) {
21
+ host.tools.registerAllOrThrow([...pack.tools], owner);
22
+ }
23
+ if (pack.providers) {
24
+ host.providers.registerAll([...pack.providers]);
25
+ }
26
+ if (pack.slashCommands) {
27
+ host.slashCommands.registerAll([...pack.slashCommands], owner);
28
+ }
29
+ if (pack.extensions && host.extensions) {
30
+ for (const ext of pack.extensions) {
31
+ unregisterExtensions.push(host.extensions.register(ext));
32
+ }
33
+ }
34
+ if (pack.setup) {
35
+ if (!opts.api) {
36
+ throw new Error(`Pack "${pack.name}" defines setup() but no PluginAPI was provided`);
37
+ }
38
+ await pack.setup(opts.api);
39
+ }
40
+ return {
41
+ pack,
42
+ owner,
43
+ async teardown() {
44
+ for (const unregister of unregisterExtensions.reverse()) {
45
+ unregister();
46
+ }
47
+ if (pack.teardown) {
48
+ if (!opts.api) {
49
+ throw new Error(`Pack "${pack.name}" defines teardown() but no PluginAPI was provided`);
50
+ }
51
+ await pack.teardown(opts.api);
52
+ }
53
+ }
54
+ };
55
+ }
56
+ async function applyWrongStackPacks(host, packs, opts = {}) {
57
+ const applied = [];
58
+ try {
59
+ for (const pack of packs) {
60
+ applied.push(await applyWrongStackPack(host, pack, opts));
61
+ }
62
+ return applied;
63
+ } catch (err) {
64
+ for (const mounted of applied.reverse()) {
65
+ await mounted.teardown().catch(() => void 0);
66
+ }
67
+ throw err;
68
+ }
69
+ }
70
+
71
+ export { applyWrongStackPack, applyWrongStackPacks, createRuntimeHostFromParts };
72
+ //# sourceMappingURL=host.js.map
73
+ //# sourceMappingURL=host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/host.ts"],"names":[],"mappings":";AAqCO,SAAS,2BAA2B,KAAA,EAAsC;AAC/E,EAAA,OAAO;AAAA,IACL,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,SAAS,KAAA,CAAM,OAAA;AAAA,IACf,QAAQ,KAAA,CAAM,MAAA;AAAA,IACd,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,WAAW,KAAA,CAAM,SAAA;AAAA,IACjB,eAAe,KAAA,CAAM,aAAA;AAAA,IACrB,SAAS,KAAA,CAAM,OAAA;AAAA,IACf,YAAY,KAAA,CAAM,UAAA;AAAA,IAClB,MAAM,QAAA,GAAW;AACf,MAAA,MAAM,MAAM,QAAA,IAAW;AAAA,IACzB;AAAA,GACF;AACF;AAaA,eAAsB,mBAAA,CACpB,IAAA,EAGA,IAAA,EACA,IAAA,GAAyB,EAAC,EACJ;AACtB,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,IAAS,IAAA,CAAK,IAAA;AACjC,EAAA,MAAM,uBAA0C,EAAC;AAEjD,EAAA,IAAI,KAAK,KAAA,EAAO;AACd,IAAA,IAAA,CAAK,MAAM,kBAAA,CAAmB,CAAC,GAAG,IAAA,CAAK,KAAK,GAAG,KAAK,CAAA;AAAA,EACtD;AACA,EAAA,IAAI,KAAK,SAAA,EAAW;AAClB,IAAA,IAAA,CAAK,UAAU,WAAA,CAAY,CAAC,GAAG,IAAA,CAAK,SAAS,CAAC,CAAA;AAAA,EAChD;AACA,EAAA,IAAI,KAAK,aAAA,EA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,KAAA,EAAO;AACxB,MAAA,OAAA,CAAQ,KAAK,MAAM,mBAAA,CAAoB,IAAA,EAAM,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,IAC1D;AACA,IAAA,OAAO,OAAA;AAAA,EACT,SAAS,GAAA,EAAK;AACZ,IAAA,KAAA,MAAW,OAAA,IAAW,OAAA,CAAQ,OAAA,EAAQ,EAAG;AACvC,MAAA,MAAM,OAAA,CAAQ,QAAA,EAAS,CAAE,KAAA,CAAM,MAAM,MAAS,CAAA;AAAA,IAChD;AACA,IAAA,MAAM,GAAA;AAAA,EACR;AACF","file":"host.js","sourcesContent":["import type {\n Agent,\n Context,\n EventBus,\n ExtensionRegistry,\n PluginAPI,\n ProviderRegistry,\n SessionWriter,\n SlashCommandRegistry,\n ToolRegistry,\n} from '@wrongstack/core';\nimport type { WrongStackPack } from './pack.js';\n\nexport interface RuntimeHost {\n agent: Agent;\n context: Context;\n events: EventBus;\n tools: ToolRegistry;\n providers: ProviderRegistry;\n slashCommands: SlashCommandRegistry;\n session: SessionWriter;\n extensions?: ExtensionRegistry;\n shutdown(): Promise<void>;\n}\n\nexport interface RuntimeHostParts {\n agent: Agent;\n context: Context;\n events: EventBus;\n tools: ToolRegistry;\n providers: ProviderRegistry;\n slashCommands: SlashCommandRegistry;\n session: SessionWriter;\n extensions?: ExtensionRegistry;\n shutdown?: () => void | Promise<void>;\n}\n\nexport function createRuntimeHostFromParts(parts: RuntimeHostParts): RuntimeHost {\n return {\n agent: parts.agent,\n context: parts.context,\n events: parts.events,\n tools: parts.tools,\n providers: parts.providers,\n slashCommands: parts.slashCommands,\n session: parts.session,\n extensions: parts.extensions,\n async shutdown() {\n await parts.shutdown?.();\n },\n };\n}\n\nexport interface ApplyPackOptions {\n owner?: string;\n api?: PluginAPI;\n}\n\nexport interface AppliedPack {\n pack: WrongStackPack;\n owner: string;\n teardown(): Promise<void>;\n}\n\nexport async function applyWrongStackPack(\n host: Pick<RuntimeHost, 'tools' | 'providers' | 'slashCommands'> & {\n extensions?: ExtensionRegistry;\n },\n pack: WrongStackPack,\n opts: ApplyPackOptions = {},\n): Promise<AppliedPack> {\n const owner = opts.owner ?? pack.name;\n const unregisterExtensions: Array<() => void> = [];\n\n if (pack.tools) {\n host.tools.registerAllOrThrow([...pack.tools], owner);\n }\n if (pack.providers) {\n host.providers.registerAll([...pack.providers]);\n }\n if (pack.slashCommands) {\n host.slashCommands.registerAll([...pack.slashCommands], owner);\n }\n if (pack.extensions && host.extensions) {\n for (const ext of pack.extensions) {\n unregisterExtensions.push(host.extensions.register(ext));\n }\n }\n if (pack.setup) {\n if (!opts.api) {\n throw new Error(`Pack \"${pack.name}\" defines setup() but no PluginAPI was provided`);\n }\n await pack.setup(opts.api);\n }\n\n return {\n pack,\n owner,\n async teardown() {\n for (const unregister of unregisterExtensions.reverse()) {\n unregister();\n }\n if (pack.teardown) {\n if (!opts.api) {\n throw new Error(`Pack \"${pack.name}\" defines teardown() but no PluginAPI was provided`);\n }\n await pack.teardown(opts.api);\n }\n },\n };\n}\n\nexport async function applyWrongStackPacks(\n host: Pick<RuntimeHost, 'tools' | 'providers' | 'slashCommands'> & {\n extensions?: ExtensionRegistry;\n },\n packs: readonly WrongStackPack[],\n opts: ApplyPackOptions = {},\n): Promise<AppliedPack[]> {\n const applied: AppliedPack[] = [];\n try {\n for (const pack of packs) {\n applied.push(await applyWrongStackPack(host, pack, opts));\n }\n return applied;\n } catch (err) {\n for (const mounted of applied.reverse()) {\n await mounted.teardown().catch(() => undefined);\n }\n throw err;\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export * from '@wrongstack/core/defaults';
2
+ export { DefaultPathResolver, DefaultTokenCounter } from '@wrongstack/core/infrastructure';
3
+ export { DefaultSystemPromptBuilder, DefaultSystemPromptBuilderOptions } from '@wrongstack/core';
4
+ export { WrongStackPack } from './pack.js';
5
+ export { AppliedPack, ApplyPackOptions, RuntimeHost, RuntimeHostParts, applyWrongStackPack, applyWrongStackPacks, createRuntimeHostFromParts } from './host.js';
package/dist/index.js ADDED
@@ -0,0 +1,79 @@
1
+ export * from '@wrongstack/core/defaults';
2
+ export { DefaultPathResolver, DefaultTokenCounter } from '@wrongstack/core/infrastructure';
3
+ export { DefaultSystemPromptBuilder } from '@wrongstack/core';
4
+
5
+ // src/index.ts
6
+
7
+ // src/host.ts
8
+ function createRuntimeHostFromParts(parts) {
9
+ return {
10
+ agent: parts.agent,
11
+ context: parts.context,
12
+ events: parts.events,
13
+ tools: parts.tools,
14
+ providers: parts.providers,
15
+ slashCommands: parts.slashCommands,
16
+ session: parts.session,
17
+ extensions: parts.extensions,
18
+ async shutdown() {
19
+ await parts.shutdown?.();
20
+ }
21
+ };
22
+ }
23
+ async function applyWrongStackPack(host, pack, opts = {}) {
24
+ const owner = opts.owner ?? pack.name;
25
+ const unregisterExtensions = [];
26
+ if (pack.tools) {
27
+ host.tools.registerAllOrThrow([...pack.tools], owner);
28
+ }
29
+ if (pack.providers) {
30
+ host.providers.registerAll([...pack.providers]);
31
+ }
32
+ if (pack.slashCommands) {
33
+ host.slashCommands.registerAll([...pack.slashCommands], owner);
34
+ }
35
+ if (pack.extensions && host.extensions) {
36
+ for (const ext of pack.extensions) {
37
+ unregisterExtensions.push(host.extensions.register(ext));
38
+ }
39
+ }
40
+ if (pack.setup) {
41
+ if (!opts.api) {
42
+ throw new Error(`Pack "${pack.name}" defines setup() but no PluginAPI was provided`);
43
+ }
44
+ await pack.setup(opts.api);
45
+ }
46
+ return {
47
+ pack,
48
+ owner,
49
+ async teardown() {
50
+ for (const unregister of unregisterExtensions.reverse()) {
51
+ unregister();
52
+ }
53
+ if (pack.teardown) {
54
+ if (!opts.api) {
55
+ throw new Error(`Pack "${pack.name}" defines teardown() but no PluginAPI was provided`);
56
+ }
57
+ await pack.teardown(opts.api);
58
+ }
59
+ }
60
+ };
61
+ }
62
+ async function applyWrongStackPacks(host, packs, opts = {}) {
63
+ const applied = [];
64
+ try {
65
+ for (const pack of packs) {
66
+ applied.push(await applyWrongStackPack(host, pack, opts));
67
+ }
68
+ return applied;
69
+ } catch (err) {
70
+ for (const mounted of applied.reverse()) {
71
+ await mounted.teardown().catch(() => void 0);
72
+ }
73
+ throw err;
74
+ }
75
+ }
76
+
77
+ export { applyWrongStackPack, applyWrongStackPacks, createRuntimeHostFromParts };
78
+ //# sourceMappingURL=index.js.map
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/host.ts"],"names":[],"mappings":";;;;;;;AAqCO,SAAS,2BAA2B,KAAA,EAAsC;AAC/E,EAAA,OAAO;AAAA,IACL,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,SAAS,KAAA,CAAM,OAAA;AAAA,IACf,QAAQ,KAAA,CAAM,MAAA;AAAA,IACd,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,WAAW,KAAA,CAAM,SAAA;AAAA,IACjB,eAAe,KAAA,CAAM,aAAA;AAAA,IACrB,SAAS,KAAA,CAAM,OAAA;AAAA,IACf,YAAY,KAAA,CAAM,UAAA;AAAA,IAClB,MAAM,QAAA,GAAW;AACf,MAAA,MAAM,MAAM,QAAA,IAAW;AAAA,IACzB;AAAA,GACF;AACF;AAaA,eAAsB,mBAAA,CACpB,IAAA,EAGA,IAAA,EACA,IAAA,GAAyB,EAAC,EACJ;AACtB,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,IAAS,IAAA,CAAK,IAAA;AACjC,EAAA,MAAM,uBAA0C,EAAC;AAEjD,EAAA,IAAI,KAAK,KAAA,EAAO;AACd,IAAA,IAAA,CAAK,MAAM,kBAAA,CAAmB,CAAC,GAAG,IAAA,CAAK,KAAK,GAAG,KAAK,CAAA;AAAA,EACtD;AACA,EAAA,IAAI,KAAK,SAAA,EAAW;AAClB,IAAA,IAAA,CAAK,UAAU,WAAA,CAAY,CAAC,GAAG,IAAA,CAAK,SAAS,CAAC,CAAA;AAAA,EAChD;AACA,EAAA,IAAI,KAAK,aAAA,EAAe;AACtB,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AO;AACxB,MAAA,OAAA,CAAQ,KAAK,MAAM,mBAAA,CAAoB,IAAA,EAAM,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,IAC1D;AACA,IAAA,OAAO,OAAA;AAAA,EACT,SAAS,GAAA,EAAK;AACZ,IAAA,KAAA,MAAW,OAAA,IAAW,OAAA,CAAQ,OAAA,EAAQ,EAAG;AACvC,MAAA,MAAM,OAAA,CAAQ,QAAA,EAAS,CAAE,KAAA,CAAM,MAAM,MAAS,CAAA;AAAA,IAChD;AACA,IAAA,MAAM,GAAA;AAAA,EACR;AACF","file":"index.js","sourcesContent":["import type {\n Agent,\n Context,\n EventBus,\n ExtensionRegistry,\n PluginAPI,\n ProviderRegistry,\n SessionWriter,\n SlashCommandRegistry,\n ToolRegistry,\n} from '@wrongstack/core';\nimport type { WrongStackPack } from './pack.js';\n\nexport interface RuntimeHost {\n agent: Agent;\n context: Context;\n events: EventBus;\n tools: ToolRegistry;\n providers: ProviderRegistry;\n slashCommands: SlashCommandRegistry;\n session: SessionWriter;\n extensions?: ExtensionRegistry;\n shutdown(): Promise<void>;\n}\n\nexport interface RuntimeHostParts {\n agent: Agent;\n context: Context;\n events: EventBus;\n tools: ToolRegistry;\n providers: ProviderRegistry;\n slashCommands: SlashCommandRegistry;\n session: SessionWriter;\n extensions?: ExtensionRegistry;\n shutdown?: () => void | Promise<void>;\n}\n\nexport function createRuntimeHostFromParts(parts: RuntimeHostParts): RuntimeHost {\n return {\n agent: parts.agent,\n context: parts.context,\n events: parts.events,\n tools: parts.tools,\n providers: parts.providers,\n slashCommands: parts.slashCommands,\n session: parts.session,\n extensions: parts.extensions,\n async shutdown() {\n await parts.shutdown?.();\n },\n };\n}\n\nexport interface ApplyPackOptions {\n owner?: string;\n api?: PluginAPI;\n}\n\nexport interface AppliedPack {\n pack: WrongStackPack;\n owner: string;\n teardown(): Promise<void>;\n}\n\nexport async function applyWrongStackPack(\n host: Pick<RuntimeHost, 'tools' | 'providers' | 'slashCommands'> & {\n extensions?: ExtensionRegistry;\n },\n pack: WrongStackPack,\n opts: ApplyPackOptions = {},\n): Promise<AppliedPack> {\n const owner = opts.owner ?? pack.name;\n const unregisterExtensions: Array<() => void> = [];\n\n if (pack.tools) {\n host.tools.registerAllOrThrow([...pack.tools], owner);\n }\n if (pack.providers) {\n host.providers.registerAll([...pack.providers]);\n }\n if (pack.slashCommands) {\n host.slashCommands.registerAll([...pack.slashCommands], owner);\n }\n if (pack.extensions && host.extensions) {\n for (const ext of pack.extensions) {\n unregisterExtensions.push(host.extensions.register(ext));\n }\n }\n if (pack.setup) {\n if (!opts.api) {\n throw new Error(`Pack \"${pack.name}\" defines setup() but no PluginAPI was provided`);\n }\n await pack.setup(opts.api);\n }\n\n return {\n pack,\n owner,\n async teardown() {\n for (const unregister of unregisterExtensions.reverse()) {\n unregister();\n }\n if (pack.teardown) {\n if (!opts.api) {\n throw new Error(`Pack \"${pack.name}\" defines teardown() but no PluginAPI was provided`);\n }\n await pack.teardown(opts.api);\n }\n },\n };\n}\n\nexport async function applyWrongStackPacks(\n host: Pick<RuntimeHost, 'tools' | 'providers' | 'slashCommands'> & {\n extensions?: ExtensionRegistry;\n },\n packs: readonly WrongStackPack[],\n opts: ApplyPackOptions = {},\n): Promise<AppliedPack[]> {\n const applied: AppliedPack[] = [];\n try {\n for (const pack of packs) {\n applied.push(await applyWrongStackPack(host, pack, opts));\n }\n return applied;\n } catch (err) {\n for (const mounted of applied.reverse()) {\n await mounted.teardown().catch(() => undefined);\n }\n throw err;\n }\n}\n"]}
package/dist/pack.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { Tool, ProviderFactory, SlashCommand, AgentExtension, PluginAPI } from '@wrongstack/core';
2
+
3
+ /**
4
+ * A first-party or third-party capability bundle that can be mounted by a
5
+ * host runtime. Tools, providers, MCP integrations, UI surfaces, and director
6
+ * features should converge on this shape instead of being hard-wired into CLI
7
+ * boot code.
8
+ */
9
+ interface WrongStackPack {
10
+ /** Stable package/pack id, e.g. "builtin-tools" or "mcp". */
11
+ name: string;
12
+ /** Human-readable one-line description for diagnostics and package lists. */
13
+ description?: string;
14
+ /** Tools to register into the host ToolRegistry. */
15
+ tools?: readonly Tool[];
16
+ /** Provider factories to register into the host ProviderRegistry. */
17
+ providers?: readonly ProviderFactory[];
18
+ /** Slash commands to register into REPL/TUI surfaces. */
19
+ slashCommands?: readonly SlashCommand[];
20
+ /** Agent lifecycle extensions to register. */
21
+ extensions?: readonly AgentExtension[];
22
+ /** Optional imperative setup for packs that need host APIs. */
23
+ setup?(api: PluginAPI): void | Promise<void>;
24
+ /** Optional best-effort teardown for resources started by setup(). */
25
+ teardown?(api: PluginAPI): void | Promise<void>;
26
+ }
27
+
28
+ export type { WrongStackPack };
package/dist/pack.js ADDED
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=pack.js.map
3
+ //# sourceMappingURL=pack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"pack.js"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@wrongstack/runtime",
3
+ "version": "0.2.0",
4
+ "license": "MIT",
5
+ "description": "WrongStack default runtime implementations and host-level composition helpers built on @wrongstack/core.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/WrongStack/WrongStack.git",
9
+ "directory": "packages/runtime"
10
+ },
11
+ "homepage": "https://github.com/WrongStack/WrongStack#readme",
12
+ "bugs": "https://github.com/WrongStack/WrongStack/issues",
13
+ "author": "ECOSTACK TECHNOLOGY OU",
14
+ "type": "module",
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "sideEffects": false,
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ },
23
+ "./pack": {
24
+ "types": "./dist/pack.d.ts",
25
+ "import": "./dist/pack.js"
26
+ },
27
+ "./host": {
28
+ "types": "./dist/host.d.ts",
29
+ "import": "./dist/host.js"
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "README.md"
36
+ ],
37
+ "dependencies": {
38
+ "@wrongstack/core": "0.3.1"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^22.19.19",
42
+ "tsup": "^8.5.1",
43
+ "typescript": "^5.9.3"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "typecheck": "tsc --noEmit",
51
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
52
+ }
53
+ }