@hasna-internal/kai-tool-cordis 0.1.1-rc.2
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 +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +104 -0
- package/README.zh.md +104 -0
- package/lib/index.js +7594 -0
- package/lib/invariant.js +23 -0
- package/lib/types/api-catalog.d.ts +96 -0
- package/lib/types/fiber-state.d.ts +28 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/inspect.d.ts +93 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/present.d.ts +91 -0
- package/lib/types/prompt.d.ts +3 -0
- package/lib/types/providers.d.ts +10 -0
- package/package.json +57 -0
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
/**
|
|
3
|
+
* Package-owned invariant companion for `@hasna-internal/kai-tool-cordis`.
|
|
4
|
+
* @module @hasna-internal/kai-tool-cordis/invariant
|
|
5
|
+
*/
|
|
6
|
+
const PACKAGE_NAME = "@hasna-internal/kai-tool-cordis";
|
|
7
|
+
/** Cordis companion plugin name. */
|
|
8
|
+
const name = "tool-cordis-invariant";
|
|
9
|
+
/** Service required before the companion can reserve package ownership. */
|
|
10
|
+
const inject = ["invariants"];
|
|
11
|
+
/**
|
|
12
|
+
* No runtime invariant: this model-facing adapter has no independent lifecycle stream; execution
|
|
13
|
+
* relations are owned by the capability seam it calls.
|
|
14
|
+
*/
|
|
15
|
+
const install = () => {};
|
|
16
|
+
/**
|
|
17
|
+
* Register this package's invariant companion.
|
|
18
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
19
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
20
|
+
*/
|
|
21
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
22
|
+
//#endregion
|
|
23
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/gen-cordis-api.ts — do not edit by hand; run
|
|
3
|
+
* `pnpm run gen-cordis-api` to regenerate (freshness-gated by
|
|
4
|
+
* `pnpm run verify-cordis-api` in doc-sync).
|
|
5
|
+
*
|
|
6
|
+
* The machine-readable cordis API catalog `cordis_inspect` serves to the
|
|
7
|
+
* model: harness services (summary + structured public method contracts),
|
|
8
|
+
* harness events (mode + structured listener contracts), and the inherited `ctx` API. Produced by
|
|
9
|
+
* the same AST walk as docs/cordis-catalog, so this data and the rendered
|
|
10
|
+
* docs cannot diverge.
|
|
11
|
+
*
|
|
12
|
+
* @module @hasna-internal/kai-tool-cordis/api-catalog
|
|
13
|
+
*/
|
|
14
|
+
/** One named parameter in a Service method or Event listener. */
|
|
15
|
+
export interface ApiParameter {
|
|
16
|
+
/** Parameter name from the exact signature. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Source-owned parameter contract. */
|
|
19
|
+
description: string;
|
|
20
|
+
}
|
|
21
|
+
/** One public service member and its source-owned contract. */
|
|
22
|
+
export interface ServiceApiMethod {
|
|
23
|
+
/** Public method signature with its body stripped. */
|
|
24
|
+
signature: string;
|
|
25
|
+
/** Method purpose and behavior. */
|
|
26
|
+
description: string;
|
|
27
|
+
/** Named parameters in signature order. */
|
|
28
|
+
parameters: readonly ApiParameter[];
|
|
29
|
+
/** Non-void result contract when documented. */
|
|
30
|
+
returns?: string;
|
|
31
|
+
/** Documented failure conditions. */
|
|
32
|
+
throws?: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
/** One harness `ctx.<key>` service and its public methods. */
|
|
35
|
+
export interface ServiceApiEntry {
|
|
36
|
+
/** The `ctx.<key>` name, e.g. `tools`. */
|
|
37
|
+
key: string;
|
|
38
|
+
/** First sentence of the service class JSDoc. */
|
|
39
|
+
summary: string;
|
|
40
|
+
/** Complete service description. */
|
|
41
|
+
description: string;
|
|
42
|
+
/** Public methods, bodies stripped, in source order. */
|
|
43
|
+
methods: readonly ServiceApiMethod[];
|
|
44
|
+
}
|
|
45
|
+
/** One harness event: its dispatch mode, exact signature, and listener contract. */
|
|
46
|
+
export interface EventApiEntry {
|
|
47
|
+
/** The scoped event name, e.g. `agent/status`. */
|
|
48
|
+
name: string;
|
|
49
|
+
/** The dispatch mode from the declaration's `@mode` tag. */
|
|
50
|
+
mode: string;
|
|
51
|
+
/** The exact listener signature, whitespace-normalized. */
|
|
52
|
+
signature: string;
|
|
53
|
+
/** First sentence of the event JSDoc. */
|
|
54
|
+
summary: string;
|
|
55
|
+
/** Complete event description. */
|
|
56
|
+
description: string;
|
|
57
|
+
/** Named listener parameters in signature order. */
|
|
58
|
+
parameters: readonly ApiParameter[];
|
|
59
|
+
}
|
|
60
|
+
/** One inherited (cordis core + loader/hmr/timer) `ctx` member group with its summary. */
|
|
61
|
+
export interface InheritedApiEntry {
|
|
62
|
+
/** The `ctx` member name(s), e.g. `ctx.on / ctx.once`. */
|
|
63
|
+
name: string;
|
|
64
|
+
/** One-line summary of what the member does. */
|
|
65
|
+
summary: string;
|
|
66
|
+
}
|
|
67
|
+
/** One named type declaration referenced by a Service or Event signature. */
|
|
68
|
+
export interface TypeApiEntry {
|
|
69
|
+
/** The exported type/interface name, e.g. `ShellRunResult`. */
|
|
70
|
+
name: string;
|
|
71
|
+
/** The full declaration text, comments stripped. */
|
|
72
|
+
declaration: string;
|
|
73
|
+
}
|
|
74
|
+
/** Every harness `ctx.<key>` service, sorted by key. */
|
|
75
|
+
export declare const SERVICE_API: readonly ServiceApiEntry[];
|
|
76
|
+
/** Every harness event, sorted by name. */
|
|
77
|
+
export declare const EVENT_API: readonly EventApiEntry[];
|
|
78
|
+
/** Shapes of every exported type the Service and Event signatures reference (transitively), sorted by name. */
|
|
79
|
+
export declare const TYPE_API: readonly TypeApiEntry[];
|
|
80
|
+
/** The inherited `ctx` API (cordis core + loader/hmr/timer), in curated order. */
|
|
81
|
+
export declare const INHERITED_CTX_API: readonly InheritedApiEntry[];
|
|
82
|
+
/**
|
|
83
|
+
* Project the Service Catalog as a compact directory or one exact coding contract.
|
|
84
|
+
* @param key - exact Service key; omit it to list all Services and method signatures.
|
|
85
|
+
* @param services - platform-specific visible Service entries.
|
|
86
|
+
* @returns compact navigation data or one detailed Service with its referenced type closure.
|
|
87
|
+
*/
|
|
88
|
+
export declare function queryServiceApi(key?: string, services?: readonly ServiceApiEntry[]): object;
|
|
89
|
+
/**
|
|
90
|
+
* Project the Event Catalog as a compact directory or one exact listener contract.
|
|
91
|
+
* @param name - exact Event name; omit it to list all Events and listener signatures.
|
|
92
|
+
* @param events - platform-specific visible Event entries.
|
|
93
|
+
* @returns compact navigation data or one detailed Event with its referenced type closure.
|
|
94
|
+
*/
|
|
95
|
+
export declare function queryEventApi(name?: string, events?: readonly EventApiEntry[]): object;
|
|
96
|
+
//# sourceMappingURL=api-catalog.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime mirror and labels for Cordis's `FiberState` const enum. A const enum has no runtime
|
|
3
|
+
* object to import, so these values mirror the pinned vendored definition while retaining its
|
|
4
|
+
* type.
|
|
5
|
+
* @module @hasna-internal/kai-tool-cordis/fiber-state
|
|
6
|
+
*/
|
|
7
|
+
import type { FiberState as FiberStateEnum } from '@deepseek-ai/cordis';
|
|
8
|
+
/** Value mirror of the cordis `FiberState` const enum (see the module doc for why a mirror exists). */
|
|
9
|
+
export declare const FiberState: {
|
|
10
|
+
readonly PENDING: FiberStateEnum.PENDING;
|
|
11
|
+
readonly LOADING: FiberStateEnum.LOADING;
|
|
12
|
+
readonly ACTIVE: FiberStateEnum.ACTIVE;
|
|
13
|
+
readonly FAILED: FiberStateEnum.FAILED;
|
|
14
|
+
readonly DISPOSED: FiberStateEnum.DISPOSED;
|
|
15
|
+
readonly UNLOADING: FiberStateEnum.UNLOADING;
|
|
16
|
+
};
|
|
17
|
+
/** The cordis `FiberState` enum type, re-exported so mirror consumers need one import. */
|
|
18
|
+
export type FiberState = FiberStateEnum;
|
|
19
|
+
/** Human-readable label for each {@link FiberState}, keyed by member (inlining-safe — no reverse mapping). */
|
|
20
|
+
export declare const STATE_LABELS: {
|
|
21
|
+
readonly 0: "pending";
|
|
22
|
+
readonly 1: "loading";
|
|
23
|
+
readonly 2: "active";
|
|
24
|
+
readonly 3: "failed";
|
|
25
|
+
readonly 4: "disposed";
|
|
26
|
+
readonly 5: "unloading";
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=fiber-state.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing Cordis runtime/package inspection, define, run, stop, and remove tools.
|
|
3
|
+
* @module @hasna-internal/kai-tool-cordis
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
export declare const name = "tool-cordis";
|
|
7
|
+
export declare const inject: string[];
|
|
8
|
+
/** Register the Cordis tools and explicit `@pluginId` context injection. */
|
|
9
|
+
export declare function apply(ctx: Context): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text renderers for `cordis_runtime_inspect`. Live facts come from the service store and
|
|
3
|
+
* the plugin registry; what each service CAN DO comes from the generated
|
|
4
|
+
* `api-catalog.ts`. This module owns the join of the two plus presentation: which
|
|
5
|
+
* lines a section prints, how compact the default report stays, and what an exact
|
|
6
|
+
* `name` adds.
|
|
7
|
+
* @module @hasna-internal/kai-tool-cordis/inspect
|
|
8
|
+
*/
|
|
9
|
+
import type { Context, Fiber } from '@deepseek-ai/cordis';
|
|
10
|
+
import type { ScopeKey } from '@hasna-internal/kai-scope';
|
|
11
|
+
import type { Agent } from '@hasna-internal/kai-agent';
|
|
12
|
+
import type { EventApiEntry, InheritedApiEntry, ServiceApiEntry, TypeApiEntry } from './api-catalog.ts';
|
|
13
|
+
/**
|
|
14
|
+
* Whether a fiber is `root` itself or mounted anywhere inside `root`'s subtree.
|
|
15
|
+
* @param fiber - the fiber to locate.
|
|
16
|
+
* @param root - the subtree root to test against.
|
|
17
|
+
* @returns true when `fiber` belongs to that subtree.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withinFiber(fiber: Fiber, root: Fiber): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Service names provided by one mount's fiber subtree.
|
|
22
|
+
* @param ctx - the runtime whose service registrations are inspected.
|
|
23
|
+
* @param fiber - the root of the mounted fiber subtree.
|
|
24
|
+
* @returns the provided service names in lexical order.
|
|
25
|
+
*/
|
|
26
|
+
export declare function providedServices(ctx: Context, fiber: Fiber): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Services a fiber declared in `inject` that do not exist yet — a settled fiber
|
|
29
|
+
* that is not active is waiting on exactly these (legal cordis semantics: it
|
|
30
|
+
* activates when the service appears).
|
|
31
|
+
* @param ctx - the context to resolve service existence against.
|
|
32
|
+
* @param fiber - the fiber whose `inject` declarations are checked.
|
|
33
|
+
* @returns the missing service names, in declaration order.
|
|
34
|
+
*/
|
|
35
|
+
export declare function missingServices(ctx: Context, fiber: Fiber): string[];
|
|
36
|
+
/**
|
|
37
|
+
* The `services` section: every live ctx service with its owning fiber and, when
|
|
38
|
+
* the generated catalog covers it, a one-line summary. The `api` section is the
|
|
39
|
+
* one that carries signatures; this one answers what exists and who provides it.
|
|
40
|
+
* @param ctx - the runtime to enumerate.
|
|
41
|
+
* @param api - the generated service entries whose summaries annotate the live ones.
|
|
42
|
+
* @returns one line per service, or a single placeholder line when none are provided.
|
|
43
|
+
*/
|
|
44
|
+
export declare function describeServices(ctx: Context, api?: readonly ServiceApiEntry[]): string[];
|
|
45
|
+
/**
|
|
46
|
+
* The `plugins` section: a flat list of every fiber the registry knows, one line
|
|
47
|
+
* per fiber with its lifecycle state, sorted by plugin name (a plugin mounted
|
|
48
|
+
* more than once repeats — one line per instance). Temporary plugins are listed
|
|
49
|
+
* like any other plugin; their ids live in the `temporary` section.
|
|
50
|
+
* @param ctx - the runtime whose registry is enumerated.
|
|
51
|
+
* @returns one line per loaded plugin fiber.
|
|
52
|
+
*/
|
|
53
|
+
export declare function describePlugins(ctx: Context): string[];
|
|
54
|
+
/**
|
|
55
|
+
* The `tools` section: the model-facing tool names the CALLING agent can see
|
|
56
|
+
* (its scoped layer shadowing/joining the restricted global tool set) — the
|
|
57
|
+
* honest answer to the tool description's "what you can call".
|
|
58
|
+
* @param ctx - the runtime whose tool registry is read.
|
|
59
|
+
* @param scope - the calling agent (the viewing scope); omitted = global view.
|
|
60
|
+
* @returns one line per visible tool.
|
|
61
|
+
*/
|
|
62
|
+
export declare function describeTools(ctx: Context, scope?: ScopeKey): string[];
|
|
63
|
+
/**
|
|
64
|
+
* The `temporary` section: one line per dynamic package this session defined,
|
|
65
|
+
* with its metadata, which halves exist, the host half's lifecycle state and
|
|
66
|
+
* provides/waits, the invoke methods it registered, and the last browser-half
|
|
67
|
+
* load report. Session-scoped like every runner verb.
|
|
68
|
+
* @param ctx - the runtime the packages live in.
|
|
69
|
+
* @param agent - the calling agent; without one there is no definition space to report.
|
|
70
|
+
* @returns one line per package, or a single placeholder line when none exist.
|
|
71
|
+
*/
|
|
72
|
+
export declare function describeDynamic(ctx: Context, agent?: Agent): string[];
|
|
73
|
+
/**
|
|
74
|
+
* Render the generated catalog against the live runtime: live catalogued services with methods,
|
|
75
|
+
* uncatalogued live services with owners, absent loadable services, referenced type shapes, and
|
|
76
|
+
* inherited Context APIs.
|
|
77
|
+
* @param ctx - the runtime to intersect the catalog with.
|
|
78
|
+
* @param api - generated service entries, replaceable in tests.
|
|
79
|
+
* @param name - exact live service key whose methods should include structured contracts; omitted for the compact catalog.
|
|
80
|
+
* @param inherited - inherited `ctx` entries, replaceable in tests.
|
|
81
|
+
* @param types - public type shapes, replaceable in tests.
|
|
82
|
+
* @returns the section lines.
|
|
83
|
+
*/
|
|
84
|
+
export declare function describeApi(ctx: Context, api?: readonly ServiceApiEntry[], name?: string, inherited?: readonly InheritedApiEntry[], types?: readonly TypeApiEntry[]): string[];
|
|
85
|
+
/**
|
|
86
|
+
* The `events` section: every harness event with its dispatch mode, one-line
|
|
87
|
+
* summary, and exact signature, closed by the waterfall caution.
|
|
88
|
+
* @param events - the event catalog (the generated one by default; injectable for tests).
|
|
89
|
+
* @param name - exact event name whose signature should include its structured contract; omitted for the compact catalog.
|
|
90
|
+
* @returns the section lines.
|
|
91
|
+
*/
|
|
92
|
+
export declare function describeEvents(events?: readonly EventApiEntry[], name?: string): string[];
|
|
93
|
+
//# sourceMappingURL=inspect.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@hasna-internal/kai-tool-cordis`.
|
|
3
|
+
* @module @hasna-internal/kai-tool-cordis/invariant
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
export declare const name = "tool-cordis-invariant";
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Register this package's invariant companion.
|
|
12
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
+
*/
|
|
15
|
+
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
+
//# sourceMappingURL=invariant.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** Pure replay-safe render intents for Cordis tools. */
|
|
2
|
+
import type { GenericCallView } from '@hasna-internal/kai-tools';
|
|
3
|
+
/**
|
|
4
|
+
* Render a runtime-inspection call.
|
|
5
|
+
* @param args - requested runtime category and optional member name.
|
|
6
|
+
* @returns replay-safe generic call presentation.
|
|
7
|
+
*/
|
|
8
|
+
export declare function presentRuntimeInspectCall(args: {
|
|
9
|
+
what?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
}): GenericCallView;
|
|
12
|
+
/**
|
|
13
|
+
* Render provider-directory inspection.
|
|
14
|
+
* @returns replay-safe generic call presentation.
|
|
15
|
+
*/
|
|
16
|
+
export declare function presentInspectListCall(): GenericCallView;
|
|
17
|
+
/**
|
|
18
|
+
* Render one provider query.
|
|
19
|
+
* @param args - target platform, provider, and method.
|
|
20
|
+
* @returns replay-safe generic call presentation.
|
|
21
|
+
*/
|
|
22
|
+
export declare function presentInspectQueryCall(args: {
|
|
23
|
+
platform: string;
|
|
24
|
+
provider: string;
|
|
25
|
+
method: string;
|
|
26
|
+
}): GenericCallView;
|
|
27
|
+
/**
|
|
28
|
+
* Render layered self-inspection.
|
|
29
|
+
* @param args - optional Plugin and Package identity.
|
|
30
|
+
* @returns replay-safe generic call presentation.
|
|
31
|
+
*/
|
|
32
|
+
export declare function presentInspectSelfCall(args: {
|
|
33
|
+
pluginId?: string;
|
|
34
|
+
packageId?: string;
|
|
35
|
+
}): GenericCallView;
|
|
36
|
+
/**
|
|
37
|
+
* Render an immutable Package source-inspection call.
|
|
38
|
+
* @param args - exact Plugin and Package identity.
|
|
39
|
+
* @returns replay-safe generic call presentation.
|
|
40
|
+
*/
|
|
41
|
+
export declare function presentPackageInspectCall(args: {
|
|
42
|
+
pluginId: string;
|
|
43
|
+
packageId: string;
|
|
44
|
+
}): GenericCallView;
|
|
45
|
+
/**
|
|
46
|
+
* Render a new or appended Package definition.
|
|
47
|
+
* @param args - target Plugin, Package metadata, and source halves.
|
|
48
|
+
* @returns replay-safe generic call presentation with source in raw input.
|
|
49
|
+
*/
|
|
50
|
+
export declare function presentDefineCall(args: {
|
|
51
|
+
plugin: {
|
|
52
|
+
kind: 'new';
|
|
53
|
+
idPrefix: string;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'existing';
|
|
56
|
+
pluginId: string;
|
|
57
|
+
};
|
|
58
|
+
name: string;
|
|
59
|
+
purpose: string;
|
|
60
|
+
code: {
|
|
61
|
+
host?: string;
|
|
62
|
+
client?: string;
|
|
63
|
+
};
|
|
64
|
+
}): GenericCallView;
|
|
65
|
+
/**
|
|
66
|
+
* Render Plugin removal.
|
|
67
|
+
* @param args - Plugin identity to remove.
|
|
68
|
+
* @returns replay-safe generic call presentation.
|
|
69
|
+
*/
|
|
70
|
+
export declare function presentUndefineCall(args: {
|
|
71
|
+
pluginId: string;
|
|
72
|
+
}): GenericCallView;
|
|
73
|
+
/**
|
|
74
|
+
* Render one exact Package activation.
|
|
75
|
+
* @param args - Plugin, Package, and activation mode.
|
|
76
|
+
* @returns replay-safe generic call presentation.
|
|
77
|
+
*/
|
|
78
|
+
export declare function presentRunCall(args: {
|
|
79
|
+
pluginId: string;
|
|
80
|
+
packageId: string;
|
|
81
|
+
mode: 'run' | 'update';
|
|
82
|
+
}): GenericCallView;
|
|
83
|
+
/**
|
|
84
|
+
* Render Plugin stop.
|
|
85
|
+
* @param args - Plugin identity to stop.
|
|
86
|
+
* @returns replay-safe generic call presentation.
|
|
87
|
+
*/
|
|
88
|
+
export declare function presentStopCall(args: {
|
|
89
|
+
pluginId: string;
|
|
90
|
+
}): GenericCallView;
|
|
91
|
+
//# sourceMappingURL=present.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Model guidance shared by the Cordis dynamic-plugin tools. */
|
|
2
|
+
export declare const CORDIS_SYSTEM_PROMPT = "# Dynamic Cordis Plugins\n\nDynamic Cordis plugins temporarily extend the current DSH process. A Plugin uses apply(ctx) to consume Services, listen to Events, provide Services, register model Tools, or register browser UI in Slots.\n\n- Plugin and Package definitions exist only in the current process. define itself does not modify repository source, configuration, or disk, and definitions do not survive a process restart.\n- The restricted execution environment prevents accidental misuse; it is not a security boundary for malicious code. Services obtained by dynamic code connect to the real runtime.\n\n## Make the user-facing plan clear first\n\n- Dynamic Cordis Plugins are one available implementation mechanism, not the default for every request. Consider whether one could help only when the user intends to design or create something, or when a temporary interface could materially aid the current work. The presence of these instructions or Tools, and discussion of Cordis itself, do not make a request a dynamic-Plugin task.\n- When Cordis is a plausible fit, infer the intended work target and lifetime from the request and conversation. Use it only when the outcome belongs to the current running harness and should be delivered as a temporary runtime extension. If that distinction is materially ambiguous, ask at most one concise question about the intended result or lifetime. Otherwise proceed with the matching workflow; do not require the user to know or choose Cordis as an implementation mechanism.\n- Once a dynamic Plugin is appropriate, decide whether the task creates a new Plugin or modifies the Plugin named by the user with @pluginId. Proceed directly when the goal is clear; do not ask for repeated confirmation.\n- Choose Host, Client, or both from the requested outcome. Do not propose a Client/browser UI when the task does not need visible page behavior, and do not avoid Client when the requested outcome is visual, interactive, or depends on page state. Host versus Client is an implementation choice; do not make the user choose it.\n- When a design direction or a potentially useful interface would materially affect the result, ask at most one concise outcome or creative-preference question and offer a few candidate directions. Otherwise proceed directly; do not conduct a multi-round interview or a complex questionnaire.\n- cordis_define only defines and presents code; it does not run it. After definition, explain the pluginId and packageId returned by the Host and whether the next step is a run or update.\n- cordis_run may require user approval. When it returns awaiting-approval, explain that the user must allow or reject it in the UI. Do not wait, retry, or claim that it is running.\n- When it returns starting, explain that the request has entered the asynchronous flow and the Client is still activating. starting does not mean success. Wait for the system to report the final result through steering context.\n- Do not request approval again after the user rejects it. After a technical failure, fix the same Plugin from its diagnostics; do not silently create a replacement Plugin.\n\n## Recommended workflow and Tools\n\nBefore creating, modifying, or repairing a Plugin, load the cordis-plugin-development Skill. The Skill provides requirement navigation, capability composition, complete examples, and troubleshooting. Treat Inspect Provider results as the source of truth for exact APIs.\n\n1. cordis_inspect_list: discover the current Host and Client Providers and their read-only query methods.\n2. cordis_inspect_query: use the returned platform, provider, method, and schema to query exact Service, Event, Builtin, Slot, Theme token, or Tool information.\n3. cordis_inspect_self: inspect the current Session's Plugins, Packages, version pointers, source, and diagnostics. Source is returned only when both pluginId and packageId are specified.\n4. cordis_define: create the first Package for a new Plugin or append an immutable Package to an existing Plugin. It defines code but does not run it.\n5. cordis_run: activate an exact Package. Use run for the first activation, restarting current, or rollback; use update to switch versions.\n6. cordis_stop: remove the current Run and pending approval request while retaining definitions, grants, and version pointers.\n7. cordis_undefine: permanently stop and delete a Plugin and all of its Packages. Use it only after confirming that the user no longer needs them.\n\n- Inspect and Catalog data only confirm capabilities, names, signatures, types, and registration protocols before code is written; they do not replace business APIs.\n- Query Service.listService and Event.listEvents without input to choose from their compact signature directories, then query the exact service or event before using it. Exact queries return the structured contract and only its referenced types.\n- At runtime, a Plugin must call real Services or listen to real Events. Do not cache, display, or depend on Inspect results as business data.\n\n## Identity, versions, and approval\n\n- pluginId identifies a Plugin that can be modified over time. For a new Plugin, submit only a semantic idPrefix of 3\u20136 lowercase English letters; the Host allocates the final ID.\n- packageId identifies one immutable Host/Client source version under a Plugin. To change code, define a new Package; never overwrite an old version.\n- pluginRunId identifies one activation attempt and connects its approval, Host/Client loading, private RPC, Run card, and errors.\n- currentPackageId is the most recent fully successful Package. Stopping, starting an update, or failing an update does not clear it.\n- nextPackageId is the target awaiting approval, being attempted, awaiting Client activation, or most recently failed.\n- A single check mark authorizes only the current Package; double check marks authorize future versions of the same Plugin. A grant remains in effect after a technical failure.\n- An update stops the old Run before starting the target Package. Failure does not automatically restart the old version; retry next with update or roll back to current with run.\n\nWhen the user enters @pluginId, the system injects identity, the default base Package, version pointers, and runtime status, but not source code:\n\n1. Call cordis_inspect_self(pluginId, packageId) to read the target source.\n2. Use cordis_define in existing mode to append a Package to the same Plugin.\n3. Call cordis_run in run or update mode according to the version relationship.\n\nNever silently create another Plugin for @pluginId. If the reference is unavailable because it was removed, belongs to another Session, or was lost on process restart, tell the user directly.\n\n## High-frequency errors that must be avoided\n\n### Services: ctx.get and inject\n\n- Read an optional Service with ctx.get('serviceName') by default and handle undefined.\n- Declare inject: ['serviceName'] on the returned Plugin object only when the Service is a hard dependency and the Plugin must enter waiting until Cordis reactivates it after the Service appears.\n- Read ctx.serviceName only after declaring that Service in inject. Never access an undeclared Service as a ctx property.\n\n```js\nreturn {\n inject: ['requiredService'],\n apply(ctx) {\n ctx.requiredService.someMethod()\n const optionalService = ctx.get('optionalService')\n if (optionalService !== undefined) optionalService.someMethod()\n },\n}\n```\n\n### Code: use plain JavaScript only\n\n- Host and Client code is not transformed by TypeScript, JSX, or a bundler.\n- Do not use TypeScript types, as, decorators, import, require, or JSX.\n- Client React code must use React.createElement(...); never write <Component />.\n- Do not assume that process, Buffer, window, document, fetch, native timers, or any other global is available. Query the corresponding platform's Builtins and Services first.\n\n### Data: do not serialize live data\n\n- Services, Events, Slots, Sessions, and their derived Cordis/DSH objects are internal live data, not ordinary JSON that can be dumped.\n- Do not apply JSON.stringify, structuredClone, recursive enumeration, full copying, or whole-object display to live data.\n- Read only the leaf fields required by the task, then construct the smallest owned data object without Host references.\n\n### Lifecycle: every side effect must be reversible\n\n- Services, Events, Tools, handlers, timers, Slots, styles, and theme overrides must all belong to the current Fiber.\n- Use ctx.effect(), ctx.on(), or official APIs that return a disposer so stop, update, or undefine removes every side effect.\n- The cordis-plugin-development Skill contains complete timer, Waterfall, Slot, theme, Tool, RPC, and React examples and troubleshooting guidance.\n\n## Host and Client\n\n- Host runs in the DSH Node.js process and is appropriate for files, networking, commands, Agent/Session access, Host Events, Services, model Tools, and JSON methods callable by the Client.\n- Client runs in the browser page and is appropriate for themes, layout, current page state, Tool cards, and Slot UI.\n- Host and Client communicate through Package-private JSON methods: Host uses harness.handle(method, handler), and Client uses host.call(method, args). The direction is Client\u2192Host, and only lossless JSON may cross it.\n- Client UI must be registered in a queried Slot; apply() cannot directly return a React Element. Query Slots.listSubTree without root to choose from the compact purpose/topology tree, then query the exact root for its full registration contract and props before writing code.\n- See the Skill and Inspect Providers for Run-specific panels and exact Slot registration patterns.\n\n## Asynchronous results and recovery\n\n- Do not wait inside a Tool for approval or browser work that can happen only after the current turn ends.\n- Asynchronous success, rejection, and runtime errors update Run state and notify you through steering context.\n- After a technical failure, use cordis_inspect_self to read the exact Package source and its message/stack. Define a corrected Package under the same Plugin and retry autonomously.\n- Use the cordis-plugin-development Skill for other failure causes, repair procedures, and complete extension patterns.";
|
|
3
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** First-party Host inspect providers registered by the Cordis tool package. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { HostCordisInspectProviderRegistration } from '@hasna-internal/kai-cordis-host-runner';
|
|
4
|
+
/**
|
|
5
|
+
* Construct Host providers over generated Catalogs, evaluator declarations, and live Tool scope.
|
|
6
|
+
* @param ctx - Host context used for Agent-scoped live Tool queries.
|
|
7
|
+
* @returns registrations for static catalogs and live Host capabilities.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hostInspectProviders(ctx: Context): HostCordisInspectProviderRegistration[];
|
|
10
|
+
//# sourceMappingURL=providers.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hasna-internal/kai-tool-cordis",
|
|
3
|
+
"description": "Self-referential cordis toolset: inspect the live runtime, mount and dispose model-written plugins",
|
|
4
|
+
"version": "0.1.1-rc.2",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/extensions/tool-cordis"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./invariant": {
|
|
22
|
+
"types": "./lib/types/invariant.d.ts",
|
|
23
|
+
"default": "./lib/invariant.js"
|
|
24
|
+
},
|
|
25
|
+
"./src/*": "./src/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib/index.js",
|
|
30
|
+
"lib/invariant.js",
|
|
31
|
+
"lib/types/**/*.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@hasna-internal/kai-invariants": "^0.1.1-rc.2",
|
|
36
|
+
"@hasna-internal/kai-llm": "^0.1.1-rc.2",
|
|
37
|
+
"@hasna-internal/kai-session": "^0.1.1-rc.2",
|
|
38
|
+
"@hasna-internal/kai-cordis-host-runner": "^0.1.1-rc.2",
|
|
39
|
+
"@hasna-internal/kai-system-prompt": "^0.1.1-rc.2",
|
|
40
|
+
"@hasna-internal/kai-scope": "^0.1.1-rc.2",
|
|
41
|
+
"@hasna-internal/kai-agent": "^0.1.1-rc.2",
|
|
42
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
43
|
+
"@hasna-internal/kai-tools": "^0.1.1-rc.2"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@hasna-internal/kai-agent": "^0.1.1-rc.2",
|
|
47
|
+
"@deepseek-ai/cordis-plugin-loader": "^1.0.2",
|
|
48
|
+
"@hasna-internal/kai-invariants": "^0.1.1-rc.2",
|
|
49
|
+
"@hasna-internal/kai-llm": "^0.1.1-rc.2",
|
|
50
|
+
"@hasna-internal/kai-cordis-host-runner": "^0.1.1-rc.2",
|
|
51
|
+
"@hasna-internal/kai-scope": "^0.1.1-rc.2",
|
|
52
|
+
"@hasna-internal/kai-system-prompt": "^0.1.1-rc.2",
|
|
53
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
54
|
+
"@hasna-internal/kai-session": "^0.1.1-rc.2",
|
|
55
|
+
"@hasna-internal/kai-tools": "^0.1.1-rc.2"
|
|
56
|
+
}
|
|
57
|
+
}
|