@cmdless/ui-sdk 0.0.4 → 0.0.6
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/README.md +17 -21
- package/dist/browser/index.d.ts +4 -74
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +29 -80
- package/dist/browser/index.js.map +1 -1
- package/dist/index.d.ts +44 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/dist/node/host.d.ts +270 -0
- package/dist/node/host.d.ts.map +1 -0
- package/dist/node/host.js +398 -0
- package/dist/node/host.js.map +1 -0
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -2
- package/dist/node/index.js.map +1 -1
- package/dist/node/utils.d.ts +9 -92
- package/dist/node/utils.d.ts.map +1 -1
- package/dist/node/utils.js +50 -325
- package/dist/node/utils.js.map +1 -1
- package/dist/node/utils.test.js +13 -87
- package/dist/node/utils.test.js.map +1 -1
- package/dist/prompts.d.ts +33 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +66 -0
- package/dist/prompts.js.map +1 -0
- package/dist/types.d.ts +25 -78
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -27
- package/dist/types.js.map +1 -1
- package/package.json +4 -10
- package/dist/app.d.ts +0 -30
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -8
- package/dist/app.js.map +0 -1
- package/dist/emitter.d.ts +0 -11
- package/dist/emitter.d.ts.map +0 -1
- package/dist/emitter.js +0 -37
- package/dist/emitter.js.map +0 -1
- package/dist/node/app.d.ts +0 -25
- package/dist/node/app.d.ts.map +0 -1
- package/dist/node/app.fixture.d.ts +0 -9
- package/dist/node/app.fixture.d.ts.map +0 -1
- package/dist/node/app.fixture.js +0 -21
- package/dist/node/app.fixture.js.map +0 -1
- package/dist/node/app.js +0 -192
- package/dist/node/app.js.map +0 -1
- package/dist/node/app.test.d.ts +0 -2
- package/dist/node/app.test.d.ts.map +0 -1
- package/dist/node/app.test.js +0 -185
- package/dist/node/app.test.js.map +0 -1
- package/dist/node/bin.d.ts +0 -3
- package/dist/node/bin.d.ts.map +0 -1
- package/dist/node/bin.js +0 -4
- package/dist/node/bin.js.map +0 -1
- package/dist/node/mcp.test.d.ts +0 -2
- package/dist/node/mcp.test.d.ts.map +0 -1
- package/dist/node/mcp.test.js +0 -92
- package/dist/node/mcp.test.js.map +0 -1
- package/dist/node/runtime.d.ts +0 -32
- package/dist/node/runtime.d.ts.map +0 -1
- package/dist/node/runtime.js +0 -20
- package/dist/node/runtime.js.map +0 -1
- package/dist/node/streams.d.ts +0 -24
- package/dist/node/streams.d.ts.map +0 -1
- package/dist/node/streams.js +0 -54
- package/dist/node/streams.js.map +0 -1
- package/dist/runtime.d.ts +0 -31
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -22
- package/dist/runtime.js.map +0 -1
package/dist/node/utils.test.js
CHANGED
|
@@ -1,91 +1,17 @@
|
|
|
1
1
|
import test from 'node:test';
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
assert.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
assert.deepEqual(getPackageName('@cmdless/ui-runtime@latest'), {
|
|
17
|
-
packageName: '@cmdless/ui-runtime',
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
test('getPackageName treats "latest" case-insensitively', () => {
|
|
21
|
-
assert.deepEqual(getPackageName('@cmdless/ui-runtime@LATEST'), {
|
|
22
|
-
packageName: '@cmdless/ui-runtime',
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
test('CmdlessUI.toArgs builds show argv with only the provided options', () => {
|
|
26
|
-
const args = CmdlessUI.toArgs({
|
|
27
|
-
kind: 'show',
|
|
28
|
-
type: 'url',
|
|
29
|
-
source: 'https://example.com',
|
|
30
|
-
app: 'agent-picker',
|
|
31
|
-
});
|
|
32
|
-
assert.deepEqual(args, ['show', 'url', 'https://example.com', '--app', 'agent-picker']);
|
|
33
|
-
});
|
|
34
|
-
test('CmdlessUI.toArgs omits options that were not provided', () => {
|
|
35
|
-
const args = CmdlessUI.toArgs({
|
|
36
|
-
kind: 'show',
|
|
37
|
-
type: 'file',
|
|
38
|
-
source: '/tmp/index.html',
|
|
39
|
-
});
|
|
40
|
-
assert.deepEqual(args, ['show', 'file', '/tmp/index.html']);
|
|
41
|
-
});
|
|
42
|
-
test('CmdlessUI.toArgs builds message-box argv', () => {
|
|
43
|
-
const args = CmdlessUI.toArgs({
|
|
44
|
-
kind: 'message-box',
|
|
45
|
-
type: 'warning',
|
|
46
|
-
message: 'are you sure?',
|
|
47
|
-
});
|
|
48
|
-
assert.deepEqual(args, ['message-box', 'warning', 'are you sure?']);
|
|
49
|
-
});
|
|
50
|
-
test('createShowCommand: a dev CMDLESS_URL override preserves the original source\'s hash route', async () => {
|
|
51
|
-
let seen;
|
|
52
|
-
const dispatcher = async (parameters) => {
|
|
53
|
-
seen = parameters;
|
|
54
|
-
return 'ok';
|
|
55
|
-
};
|
|
56
|
-
const show = createShowCommand({
|
|
57
|
-
params: () => ({ type: 'file', source: '/dist/index.html#/pick-agent' }),
|
|
58
|
-
dispatcher,
|
|
59
|
-
});
|
|
60
|
-
const originalUrl = CmdlessEnv.url;
|
|
61
|
-
CmdlessEnv.url = 'http://localhost:5173/';
|
|
62
|
-
try {
|
|
63
|
-
await show();
|
|
64
|
-
}
|
|
65
|
-
finally {
|
|
66
|
-
CmdlessEnv.url = originalUrl;
|
|
67
|
-
}
|
|
68
|
-
assert.equal(seen?.type, 'url');
|
|
69
|
-
assert.equal(seen?.source, 'http://localhost:5173/#/pick-agent');
|
|
70
|
-
});
|
|
71
|
-
test('createShowCommand: a dev CMDLESS_URL override with no hash in the original source is used as-is', async () => {
|
|
72
|
-
let seen;
|
|
73
|
-
const dispatcher = async (parameters) => {
|
|
74
|
-
seen = parameters;
|
|
75
|
-
return 'ok';
|
|
76
|
-
};
|
|
77
|
-
const show = createShowCommand({
|
|
78
|
-
params: () => ({ type: 'file', source: '/dist/index.html' }),
|
|
79
|
-
dispatcher,
|
|
80
|
-
});
|
|
81
|
-
const originalUrl = CmdlessEnv.url;
|
|
82
|
-
CmdlessEnv.url = 'http://localhost:5173/';
|
|
83
|
-
try {
|
|
84
|
-
await show();
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
CmdlessEnv.url = originalUrl;
|
|
88
|
-
}
|
|
89
|
-
assert.equal(seen?.source, 'http://localhost:5173/');
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { getEphemeralPrefix, isEphemeralUserData } from './utils.js';
|
|
6
|
+
test('isEphemeralUserData only accepts an ephemeral app\'s directory inside the ephemeral folder', () => {
|
|
7
|
+
const id = '1b85461e-34c0-4186-91c6-f8f134158e2e';
|
|
8
|
+
const root = path.join(os.tmpdir(), getEphemeralPrefix());
|
|
9
|
+
assert.equal(isEphemeralUserData(path.join(root, id)), true);
|
|
10
|
+
assert.equal(isEphemeralUserData(path.join('/anywhere/else', getEphemeralPrefix(), id)), true);
|
|
11
|
+
assert.equal(isEphemeralUserData(path.join(os.tmpdir(), id)), false);
|
|
12
|
+
assert.equal(isEphemeralUserData(path.join(root, 'not-an-id')), false);
|
|
13
|
+
assert.equal(isEphemeralUserData(path.join(root, id, '..')), false);
|
|
14
|
+
assert.equal(isEphemeralUserData(path.join(root, id, 'nested')), false);
|
|
15
|
+
assert.equal(isEphemeralUserData(path.join('.cmdless.ui', id)), false);
|
|
90
16
|
});
|
|
91
17
|
//# sourceMappingURL=utils.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../src/node/utils.test.ts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CAAC,EAAE,KAAK,CAAC,CAAC;IACpE,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACxE,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AdaptiveCard, CardEvent } from './types.js';
|
|
2
|
+
export type ElicitationRequest = {
|
|
3
|
+
message: string;
|
|
4
|
+
requestedSchema: Record<string, unknown>;
|
|
5
|
+
};
|
|
6
|
+
export type ElicitationResult = {
|
|
7
|
+
action: 'accept';
|
|
8
|
+
content: Record<string, unknown>;
|
|
9
|
+
} | {
|
|
10
|
+
action: 'decline';
|
|
11
|
+
} | {
|
|
12
|
+
action: 'cancel';
|
|
13
|
+
};
|
|
14
|
+
export declare function elicitationCard({ message, requestedSchema }: ElicitationRequest): AdaptiveCard;
|
|
15
|
+
export declare function elicitationResult(submitted: CardEvent | undefined): ElicitationResult;
|
|
16
|
+
export type PermissionRequest = {
|
|
17
|
+
title: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
options: {
|
|
20
|
+
optionId: string;
|
|
21
|
+
name: string;
|
|
22
|
+
kind: string;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
export type PermissionOutcome = {
|
|
26
|
+
outcome: 'selected';
|
|
27
|
+
optionId: string;
|
|
28
|
+
} | {
|
|
29
|
+
outcome: 'cancelled';
|
|
30
|
+
};
|
|
31
|
+
export declare function permissionCard({ title, description, options }: PermissionRequest): AdaptiveCard;
|
|
32
|
+
export declare function permissionResult(submitted: CardEvent | undefined): PermissionOutcome;
|
|
33
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|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AAiB,CAGpF"}
|
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// what the form in an elicitation card is called among the card's inputs
|
|
2
|
+
const CONTENT = 'content';
|
|
3
|
+
// the requested schema as react-jsonschema-form wants it, with the uiSchema
|
|
4
|
+
// that goes with it: legacy enumNames are labels it reads from the uiSchema,
|
|
5
|
+
// and a multi-select's items are unique (or it draws a list to add to)
|
|
6
|
+
function formSchema(requested) {
|
|
7
|
+
const properties = {};
|
|
8
|
+
const uiSchema = {};
|
|
9
|
+
for (const [name, field] of Object.entries((requested.properties ?? {}))) {
|
|
10
|
+
const { enumNames, ...rest } = field;
|
|
11
|
+
properties[name] = rest.type === 'array' ? { ...rest, uniqueItems: true } : rest;
|
|
12
|
+
if (Array.isArray(enumNames))
|
|
13
|
+
uiSchema[name] = { 'ui:enumNames': enumNames };
|
|
14
|
+
}
|
|
15
|
+
return { schema: { ...requested, type: 'object', properties }, uiSchema };
|
|
16
|
+
}
|
|
17
|
+
// a card asking what an elicitation asks: its message, its schema as a form,
|
|
18
|
+
// and Accept (once the form is valid) or Decline (whatever's in it)
|
|
19
|
+
export function elicitationCard({ message, requestedSchema }) {
|
|
20
|
+
const { schema, uiSchema } = formSchema(requestedSchema);
|
|
21
|
+
return {
|
|
22
|
+
type: 'AdaptiveCard',
|
|
23
|
+
version: '1.5',
|
|
24
|
+
body: [
|
|
25
|
+
{ type: 'TextBlock', text: message, wrap: true },
|
|
26
|
+
{ type: 'Input.JsonSchema', id: CONTENT, schema, uiSchema },
|
|
27
|
+
],
|
|
28
|
+
actions: [
|
|
29
|
+
{ type: 'Action.Submit', title: 'Accept', style: 'positive', data: { action: 'accept' } },
|
|
30
|
+
{ type: 'Action.Submit', title: 'Decline', associatedInputs: 'none', data: { action: 'decline' } },
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// what an elicitation card ended with, as the elicitation's answer
|
|
35
|
+
export function elicitationResult(submitted) {
|
|
36
|
+
const action = submitted?.action.data?.action;
|
|
37
|
+
if (action === 'accept')
|
|
38
|
+
return { action, content: (submitted.inputs[CONTENT] ?? {}) };
|
|
39
|
+
if (action === 'decline')
|
|
40
|
+
return { action };
|
|
41
|
+
return { action: 'cancel' };
|
|
42
|
+
}
|
|
43
|
+
// a card asking a permission request: its title and description, and a
|
|
44
|
+
// button per option - allowing ones first in line, rejecting ones in red
|
|
45
|
+
export function permissionCard({ title, description, options }) {
|
|
46
|
+
return {
|
|
47
|
+
type: 'AdaptiveCard',
|
|
48
|
+
version: '1.5',
|
|
49
|
+
body: [
|
|
50
|
+
{ type: 'TextBlock', text: title, weight: 'Bolder', size: 'Medium', wrap: true },
|
|
51
|
+
...(description ? [{ type: 'TextBlock', text: description, wrap: true, isSubtle: true }] : []),
|
|
52
|
+
],
|
|
53
|
+
actions: options.map(({ optionId, name, kind }) => ({
|
|
54
|
+
type: 'Action.Submit',
|
|
55
|
+
title: name,
|
|
56
|
+
style: kind.startsWith('allow') ? 'positive' : kind.startsWith('reject') ? 'destructive' : 'default',
|
|
57
|
+
data: { optionId },
|
|
58
|
+
})),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// what a permission card ended with, as the request's outcome
|
|
62
|
+
export function permissionResult(submitted) {
|
|
63
|
+
const optionId = submitted?.action.data?.optionId;
|
|
64
|
+
return optionId === undefined ? { outcome: 'cancelled' } : { outcome: 'selected', optionId };
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAeA,yEAAyE;AACzE,MAAM,OAAO,GAAG,SAAS,CAAC;AAI1B,4EAA4E;AAC5E,6EAA6E;AAC7E,uEAAuE;AACvE,SAAS,UAAU,CAAC,SAAiB;IACnC,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAA2B,EAAE,CAAC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,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;YACpG,IAAI,EAAE,EAAE,QAAQ,EAAE;SACnB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,gBAAgB,CAAC,SAAgC;IAC/D,MAAM,QAAQ,GAAI,SAAS,EAAE,MAAM,CAAC,IAA0C,EAAE,QAAQ,CAAC;IACzF,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAC/F,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,83 +1,30 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const SetupOptionsSchema: z.ZodObject<{
|
|
3
|
-
app: z.ZodOptional<z.ZodString>;
|
|
4
|
-
parent: z.ZodOptional<z.ZodNumber>;
|
|
5
|
-
}, z.core.$strip>;
|
|
6
|
-
export type SetupOptions = z.infer<typeof SetupOptionsSchema>;
|
|
7
|
-
export declare const SetupParamsSchema: z.ZodObject<{
|
|
8
|
-
app: z.ZodOptional<z.ZodString>;
|
|
9
|
-
parent: z.ZodOptional<z.ZodNumber>;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
export type SetupParams = z.infer<typeof SetupParamsSchema>;
|
|
12
|
-
export declare const ShowOptionsSchema: z.ZodObject<{
|
|
13
|
-
app: z.ZodOptional<z.ZodString>;
|
|
14
|
-
parent: z.ZodOptional<z.ZodNumber>;
|
|
15
|
-
width: z.ZodOptional<z.ZodNumber>;
|
|
16
|
-
height: z.ZodOptional<z.ZodNumber>;
|
|
17
|
-
address: z.ZodOptional<z.ZodString>;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
export type ShowOptions = z.infer<typeof ShowOptionsSchema>;
|
|
20
1
|
export declare const ShowTypes: readonly ['url', 'file'];
|
|
21
2
|
export type ShowType = typeof ShowTypes[number];
|
|
22
|
-
export declare const ShowParamsSchema: z.ZodObject<{
|
|
23
|
-
app: z.ZodOptional<z.ZodString>;
|
|
24
|
-
parent: z.ZodOptional<z.ZodNumber>;
|
|
25
|
-
width: z.ZodOptional<z.ZodNumber>;
|
|
26
|
-
height: z.ZodOptional<z.ZodNumber>;
|
|
27
|
-
address: z.ZodOptional<z.ZodString>;
|
|
28
|
-
kind: z.ZodLiteral<"show">;
|
|
29
|
-
type: z.ZodEnum<{
|
|
30
|
-
file: "file";
|
|
31
|
-
url: "url";
|
|
32
|
-
}>;
|
|
33
|
-
source: z.ZodString;
|
|
34
|
-
}, z.core.$strip>;
|
|
35
|
-
export type ShowParams = z.infer<typeof ShowParamsSchema>;
|
|
36
3
|
export declare const MessageBoxTypes: readonly ['none', 'info', 'error', 'question', 'warning'];
|
|
37
4
|
export type MessageBoxType = typeof MessageBoxTypes[number];
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
export type
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
kind: z.ZodLiteral<"show">;
|
|
64
|
-
type: z.ZodEnum<{
|
|
65
|
-
file: "file";
|
|
66
|
-
url: "url";
|
|
67
|
-
}>;
|
|
68
|
-
source: z.ZodString;
|
|
69
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
70
|
-
app: z.ZodOptional<z.ZodString>;
|
|
71
|
-
parent: z.ZodOptional<z.ZodNumber>;
|
|
72
|
-
kind: z.ZodLiteral<"message-box">;
|
|
73
|
-
type: z.ZodEnum<{
|
|
74
|
-
error: "error";
|
|
75
|
-
info: "info";
|
|
76
|
-
none: "none";
|
|
77
|
-
question: "question";
|
|
78
|
-
warning: "warning";
|
|
79
|
-
}>;
|
|
80
|
-
message: z.ZodString;
|
|
81
|
-
}, z.core.$strip>], "kind">;
|
|
82
|
-
export type Params = z.infer<typeof ParamsSchema>;
|
|
5
|
+
export type AdaptiveCard = {
|
|
6
|
+
type: 'AdaptiveCard';
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type CardEvent = {
|
|
10
|
+
action: {
|
|
11
|
+
type: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
verb?: string;
|
|
15
|
+
data?: unknown;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
inputs: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
export type CardView = {
|
|
21
|
+
card: AdaptiveCard;
|
|
22
|
+
hostConfig?: object;
|
|
23
|
+
};
|
|
24
|
+
export type FormView = {
|
|
25
|
+
schema: object;
|
|
26
|
+
uiSchema?: object;
|
|
27
|
+
formData?: unknown;
|
|
28
|
+
submitText?: string;
|
|
29
|
+
};
|
|
83
30
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,SAAS,YAAI,KAAK,EAAE,MAAM,CAAU,CAAC;AAClD,MAAM,MAAM,QAAQ,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;AAGhD,eAAO,MAAM,eAAe,YAAI,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAU,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AAI5D,MAAM,MAAM,YAAY,GAAG;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAM5E,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAA,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC5G,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC;AAKF,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAInE,MAAM,MAAM,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
// zod schemas are the source of truth here - types are inferred from them
|
|
3
|
-
// (not hand-duplicated) so the same schemas can be reused directly in an
|
|
4
|
-
// app schema (see runtime.ts) without drifting from what this module's own
|
|
5
|
-
// plain-TS consumers (e.g. ui-runtime's main/index.ts) already expect.
|
|
6
|
-
export const SetupOptionsSchema = z.object({
|
|
7
|
-
app: z.string().optional(),
|
|
8
|
-
parent: z.number().optional(),
|
|
9
|
-
});
|
|
10
|
-
export const SetupParamsSchema = SetupOptionsSchema;
|
|
11
|
-
export const ShowOptionsSchema = SetupParamsSchema.extend({
|
|
12
|
-
width: z.number().optional(),
|
|
13
|
-
height: z.number().optional(),
|
|
14
|
-
address: z.string().optional(),
|
|
15
|
-
});
|
|
1
|
+
// what a window shows: a URL, or a file
|
|
16
2
|
export const ShowTypes = ['url', 'file'];
|
|
17
|
-
|
|
18
|
-
kind: z.literal('show'),
|
|
19
|
-
type: z.enum(ShowTypes),
|
|
20
|
-
source: z.string(),
|
|
21
|
-
});
|
|
3
|
+
// the kinds of message box a dialog can be
|
|
22
4
|
export const MessageBoxTypes = ['none', 'info', 'error', 'question', 'warning'];
|
|
23
|
-
export const MessageBoxOptionsSchema = SetupParamsSchema;
|
|
24
|
-
export const MessageBoxParamsSchema = MessageBoxOptionsSchema.extend({
|
|
25
|
-
kind: z.literal('message-box'),
|
|
26
|
-
type: z.enum(MessageBoxTypes),
|
|
27
|
-
message: z.string(),
|
|
28
|
-
});
|
|
29
|
-
export const ParamsSchema = z.discriminatedUnion('kind', [ShowParamsSchema, MessageBoxParamsSchema]);
|
|
30
5
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,CAAU,CAAC;AAGlD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmdless/ui-sdk",
|
|
3
3
|
"description": "Build cross platform desktop apps built on Electron.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": {
|
|
@@ -12,9 +12,6 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git+https://github.com/cmdless/electron.git"
|
|
14
14
|
},
|
|
15
|
-
"bin": {
|
|
16
|
-
"ui-sdk": "./dist/node/bin.js"
|
|
17
|
-
},
|
|
18
15
|
"exports": {
|
|
19
16
|
"./node": {
|
|
20
17
|
"types": "./dist/node/index.d.ts",
|
|
@@ -40,12 +37,9 @@
|
|
|
40
37
|
"test": "node ../../scripts/run-tests.mjs"
|
|
41
38
|
},
|
|
42
39
|
"dependencies": {
|
|
43
|
-
"@cmdless/
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
"vscode-jsonrpc": "9.0.2",
|
|
47
|
-
"ws": "8.21.3",
|
|
48
|
-
"zod": "4.6.5"
|
|
40
|
+
"@cmdless/core": "^0.0.1",
|
|
41
|
+
"@cmdless/rpc-sdk": "^0.0.4",
|
|
42
|
+
"ws": "8.21.3"
|
|
49
43
|
},
|
|
50
44
|
"devDependencies": {
|
|
51
45
|
"@types/ws": "8.5.13"
|
package/dist/app.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { RpcProtocol } from '@cmdless/rpc-sdk';
|
|
3
|
-
export type AppTool<InSchema extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, OutSchema extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, P extends RpcProtocol = RpcProtocol> = {
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
inputSchema: InSchema;
|
|
7
|
-
outputSchema: OutSchema;
|
|
8
|
-
protocol?: P;
|
|
9
|
-
};
|
|
10
|
-
export type ToolInput<T extends AppTool> = z.infer<T['inputSchema']>;
|
|
11
|
-
export type ToolOutput<T extends AppTool> = z.infer<T['outputSchema']>;
|
|
12
|
-
export type ToolProtocol<T extends AppTool> = T extends AppTool<infer _In, infer _Out, infer P> ? P : never;
|
|
13
|
-
declare function tool<InSchema extends z.ZodObject<z.ZodRawShape>, OutSchema extends z.ZodObject<z.ZodRawShape>, P extends RpcProtocol = RpcProtocol>(name: string, description: string, schemas: {
|
|
14
|
-
input: InSchema;
|
|
15
|
-
output: OutSchema;
|
|
16
|
-
protocol?: P;
|
|
17
|
-
}): AppTool<InSchema, OutSchema, P>;
|
|
18
|
-
export type AppToolsSpec = Record<string, AppTool>;
|
|
19
|
-
export type AppSpec<T extends AppToolsSpec = AppToolsSpec> = {
|
|
20
|
-
name: string;
|
|
21
|
-
description?: string;
|
|
22
|
-
tools: T;
|
|
23
|
-
};
|
|
24
|
-
export type AppFactory<T extends AppToolsSpec> = (parameters: {
|
|
25
|
-
tool: typeof tool;
|
|
26
|
-
z: typeof z;
|
|
27
|
-
}) => AppSpec<T>;
|
|
28
|
-
export declare function defineApp<const T extends AppToolsSpec>(factory: AppFactory<T>): AppSpec<T>;
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAqBpD,MAAM,MAAM,OAAO,CAAC,QAAQ,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,SAAS,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,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,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,YAAY,IAAI,CAAC,UAAU,EAAE;IAC5D,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB,CAAC,EAAE,OAAO,CAAC,CAAC;CACb,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAEjB,wBAAgB,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,YAAY,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE1F"}
|
package/dist/app.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
function tool(name, description, schemas) {
|
|
3
|
-
return { name, description, inputSchema: schemas.input, outputSchema: schemas.output, protocol: schemas.protocol };
|
|
4
|
-
}
|
|
5
|
-
export function defineApp(factory) {
|
|
6
|
-
return factory({ tool, z });
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkCxB,SAAS,IAAI,CACX,IAAY,EACZ,WAAmB,EACnB,OAA6D;IAE7D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;AACrH,CAAC;AAeD,MAAM,UAAU,SAAS,CAA+B,OAAsB;IAC5E,OAAO,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/emitter.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type EmitterEventMap = Record<string, readonly unknown[]>;
|
|
2
|
-
export declare class Emitter<TSend extends EmitterEventMap = {}, TReceive extends EmitterEventMap = TSend> {
|
|
3
|
-
private readonly target;
|
|
4
|
-
private readonly handlers;
|
|
5
|
-
on<K extends keyof TReceive>(type: K, handler: (...args: TReceive[K]) => void): this;
|
|
6
|
-
once<K extends keyof TReceive>(type: K, handler: (...args: TReceive[K]) => void): this;
|
|
7
|
-
off<K extends keyof TReceive>(type: K, handler: (...args: TReceive[K]) => void): this;
|
|
8
|
-
emit<K extends keyof TSend>(type: K, ...args: TSend[K]): boolean;
|
|
9
|
-
subscribe<K extends keyof TReceive>(type: K, handler: (...args: TReceive[K]) => void): () => void;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=emitter.d.ts.map
|
package/dist/emitter.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC;AAEjE,qBAAa,OAAO,CAAC,KAAK,SAAS,eAAe,GAAG,EAAE,EAAE,QAAQ,SAAS,eAAe,GAAG,KAAK;IAC/F,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0C;IAEnE,EAAE,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAOnF;IAED,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAQrF;IAED,GAAG,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI,CAOpF;IAED,IAAI,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAE/D;IAED,SAAS,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAGhG;CACF"}
|
package/dist/emitter.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export class Emitter {
|
|
2
|
-
target = new EventTarget();
|
|
3
|
-
handlers = new WeakMap();
|
|
4
|
-
on(type, handler) {
|
|
5
|
-
const wrapped = (event) => {
|
|
6
|
-
handler(...event.detail);
|
|
7
|
-
};
|
|
8
|
-
this.handlers.set(handler, wrapped);
|
|
9
|
-
this.target.addEventListener(type, wrapped);
|
|
10
|
-
return this;
|
|
11
|
-
}
|
|
12
|
-
once(type, handler) {
|
|
13
|
-
const wrapped = (event) => {
|
|
14
|
-
this.handlers.delete(handler);
|
|
15
|
-
handler(...event.detail);
|
|
16
|
-
};
|
|
17
|
-
this.handlers.set(handler, wrapped);
|
|
18
|
-
this.target.addEventListener(type, wrapped, { once: true });
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
off(type, handler) {
|
|
22
|
-
const wrapped = this.handlers.get(handler);
|
|
23
|
-
if (wrapped) {
|
|
24
|
-
this.target.removeEventListener(type, wrapped);
|
|
25
|
-
this.handlers.delete(handler);
|
|
26
|
-
}
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
emit(type, ...args) {
|
|
30
|
-
return this.target.dispatchEvent(new CustomEvent(type, { detail: args }));
|
|
31
|
-
}
|
|
32
|
-
subscribe(type, handler) {
|
|
33
|
-
this.on(type, handler);
|
|
34
|
-
return () => this.off(type, handler);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=emitter.js.map
|
package/dist/emitter.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../src/emitter.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,OAAO;IACD,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IAC3B,QAAQ,GAAG,IAAI,OAAO,EAA2B,CAAC;IAEnE,EAAE,CAA2B,IAAO,EAAE,OAAuC;QAC3E,MAAM,OAAO,GAAkB,CAAC,KAAK,EAAE,EAAE;YACvC,OAAO,CAAC,GAAI,KAAkC,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAc,EAAE,OAAO,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAA2B,IAAO,EAAE,OAAuC;QAC7E,MAAM,OAAO,GAAkB,CAAC,KAAK,EAAE,EAAE;YACvC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC9B,OAAO,CAAC,GAAI,KAAkC,CAAC,MAAM,CAAC,CAAC;QACzD,CAAC,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAc,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG,CAA2B,IAAO,EAAE,OAAuC;QAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAc,EAAE,OAAO,CAAC,CAAC;YACzD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAwB,IAAO,EAAE,GAAG,IAAc;QACpD,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,IAAc,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,SAAS,CAA2B,IAAO,EAAE,OAAuC;QAClF,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvB,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;CACF"}
|
package/dist/node/app.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import type { AppSpec, AppTool, AppToolsSpec, ToolInput, ToolOutput } from '../app.js';
|
|
3
|
-
export type ToolHandler<T extends AppTool> = (input: ToolInput<T>) => Promise<ToolOutput<T>>;
|
|
4
|
-
export type ToolHandlers<T extends AppToolsSpec> = {
|
|
5
|
-
[K in keyof T]: ToolHandler<T[K]>;
|
|
6
|
-
};
|
|
7
|
-
export type McpHandle = {
|
|
8
|
-
address: string;
|
|
9
|
-
dispose: () => Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
export type App<T extends AppToolsSpec> = {
|
|
12
|
-
spec: AppSpec<T>;
|
|
13
|
-
tools: ToolHandlers<T>;
|
|
14
|
-
cli: () => Command;
|
|
15
|
-
run: (argv?: readonly string[]) => Promise<void>;
|
|
16
|
-
mcp: () => Promise<McpHandle>;
|
|
17
|
-
};
|
|
18
|
-
export type AppSetup<T extends AppToolsSpec> = () => ToolHandlers<T>;
|
|
19
|
-
export type AppOptions<T extends AppToolsSpec> = {
|
|
20
|
-
spec: AppSpec<T>;
|
|
21
|
-
setup: AppSetup<T>;
|
|
22
|
-
startup?: (app: App<T>) => void | Promise<void>;
|
|
23
|
-
};
|
|
24
|
-
export declare function createApp<T extends AppToolsSpec>(options: AppOptions<T>): () => App<T>;
|
|
25
|
-
//# sourceMappingURL=app.d.ts.map
|
package/dist/node/app.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/node/app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvF,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7F,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,YAAY,IAAI;KAChD,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,YAAY,IAAI;IACxC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAKvB,GAAG,EAAE,MAAM,OAAO,CAAC;IAEnB,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAKjD,GAAG,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;CAC/B,CAAC;AA8LF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,YAAY,IAAI,MAAM,YAAY,CAAC,CAAC,CAAC,CAAC;AAErE,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,YAAY,IAAI;IAC/C,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAInB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD,CAAC;AAMF,wBAAgB,SAAS,CAAC,CAAC,SAAS,YAAY,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CActF"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare const createTestApp: () => import("./app.js").App<{
|
|
2
|
-
readonly echo: import("../app.js").AppTool<import("zod").ZodObject<{
|
|
3
|
-
text: import("zod").ZodString;
|
|
4
|
-
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
5
|
-
text: import("zod").ZodString;
|
|
6
|
-
}, import("zod/v4/core").$strip>, import("@cmdless/rpc-sdk").RpcProtocol>;
|
|
7
|
-
}>;
|
|
8
|
-
export default createTestApp;
|
|
9
|
-
//# sourceMappingURL=app.fixture.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.fixture.d.ts","sourceRoot":"","sources":["../../src/node/app.fixture.ts"],"names":[],"mappings":"AAaA,QAAA,MAAM,aAAa;;;;;;EAKjB,CAAC;eAEY,aAAa"}
|
package/dist/node/app.fixture.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineApp } from '../index.js';
|
|
2
|
-
import { createApp } from './index.js';
|
|
3
|
-
const spec = defineApp(({ tool, z }) => ({
|
|
4
|
-
name: 'test-fixture-app',
|
|
5
|
-
tools: {
|
|
6
|
-
echo: tool('echo', 'Echo input', {
|
|
7
|
-
input: z.object({ text: z.string() }),
|
|
8
|
-
output: z.object({ text: z.string() }),
|
|
9
|
-
}),
|
|
10
|
-
},
|
|
11
|
-
}));
|
|
12
|
-
const createTestApp = createApp({
|
|
13
|
-
spec,
|
|
14
|
-
setup: () => ({
|
|
15
|
-
echo: async ({ text }) => ({ text }),
|
|
16
|
-
}),
|
|
17
|
-
});
|
|
18
|
-
export default createTestApp;
|
|
19
|
-
if (import.meta.url === `file://${process.argv[1]}`)
|
|
20
|
-
await createTestApp().run();
|
|
21
|
-
//# sourceMappingURL=app.fixture.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.fixture.js","sourceRoot":"","sources":["../../src/node/app.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACvC,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE;QACL,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE;YAC/B,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YACrC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;SACvC,CAAC;KACH;CACF,CAAC,CAAC,CAAC;AAEJ,MAAM,aAAa,GAAG,SAAS,CAAC;IAC9B,IAAI;IACJ,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACZ,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;KACrC,CAAC;CACH,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC;AAE7B,IAAI,OAAO,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;IACjD,MAAM,aAAa,EAAE,CAAC,GAAG,EAAE,CAAC"}
|