@xiashe/sdk 0.1.43 → 0.1.44
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 +6 -0
- package/index.mjs +7 -1
- package/package.json +4 -2
- package/runtimeOpenUi.d.mts +7 -0
- package/runtimeOpenUi.mjs +98 -0
- package/runtimePresentation.d.mts +3 -1
- package/runtimePresentation.mjs +3 -2
- package/runtimeView.d.mts +21 -0
- package/runtimeView.mjs +117 -0
package/README.md
CHANGED
|
@@ -47,3 +47,9 @@ For an operator-enabled public action, use `grantConnector({ publicAccess: true,
|
|
|
47
47
|
- `launchRuntimeRun({ releaseId, input, connections, publicActionIds, creatorServiceIds, requestKey, targetAgentConnectionId, executionMode? })` validates and grants the explicitly confirmed scope, then queues execution atomically. It stores only declared parameters and connection revisions for this exact release.
|
|
48
48
|
|
|
49
49
|
Keep `values` out of logs, command arguments, Skill files, runtime inputs and persisted Agent state. A replacement invalidates old approvals; the new connection must be selected and approved again. Creator-provided services use the existing constrained service broker, never transfer the creator's raw credential to a consumer or Agent.
|
|
50
|
+
|
|
51
|
+
## Composable result views
|
|
52
|
+
|
|
53
|
+
`getRuntimeViewGuide()` generates instructions from the platform component schemas. `compileRuntimeView(presentation, openUiSource)` compiles OpenUI Lang into the optional static `presentation.view` (`xiashe.result@1`). Existing blocks remain the source of truth; no tools, mutations, queries, dynamic code or cloud service is run. Use Report, Metrics, Records, Comparison, Sources, Gaps, Creator and Section under a root Stack, referencing every block exactly once. Local compiler dependencies are pinned; set `DO_NOT_TRACK=1` during installation to disable upstream install telemetry.
|
|
54
|
+
|
|
55
|
+
Agent delivery continues returning Markdown and portable HTML for hosts without the registered component library. New creator attribution includes stableCardUrl and revision while preserving cardUrl for older clients. Metadata refresh never grants execution permissions.
|
package/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ export { serveRuntimeMcp } from './runtimeMcp.mjs';
|
|
|
19
19
|
|
|
20
20
|
export { safeOutput as redactCredentials } from './outputSafety.mjs';
|
|
21
21
|
|
|
22
|
-
export const VERSION = '0.1.
|
|
22
|
+
export const VERSION = '0.1.44';
|
|
23
23
|
export { probeRuntimeGateway, runtimeSetupTemplate } from './runtimeSetup.mjs';
|
|
24
24
|
|
|
25
25
|
export const DEFAULTS = {
|
|
@@ -753,6 +753,10 @@ export class XiasheClient {
|
|
|
753
753
|
return this.mutation(api.runtimeHosts.finishRun, this.runtimeHostAuth({ runId, leaseToken, eventId, status, resultJson }));
|
|
754
754
|
}
|
|
755
755
|
|
|
756
|
+
async getSkillMetadata(skillCatalogId) {
|
|
757
|
+
return this.query(api.skillSync.getForCatalog, this.authArgs({ skillCatalogId }));
|
|
758
|
+
}
|
|
759
|
+
|
|
756
760
|
async getRuntimeDelivery(runId) {
|
|
757
761
|
return this.query(api.superconnector.delivery, this.authArgs({ runId }));
|
|
758
762
|
}
|
|
@@ -1778,3 +1782,5 @@ export {
|
|
|
1778
1782
|
diagnoseAlipay402Resource,
|
|
1779
1783
|
createAlipay402SupportReport
|
|
1780
1784
|
} from './alipayWallet.mjs';
|
|
1785
|
+
|
|
1786
|
+
export { compileRuntimeView, getRuntimeViewGuide } from './runtimeOpenUi.mjs';
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiashe/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./index.mjs"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"convex": "^1.34.0"
|
|
10
|
+
"convex": "^1.34.0",
|
|
11
|
+
"@openuidev/lang-core": "1.0.1",
|
|
12
|
+
"zod": "4.3.6"
|
|
11
13
|
},
|
|
12
14
|
"engines": {
|
|
13
15
|
"node": ">=20"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RuntimePresentation } from "./runtimePresentation.mjs";
|
|
2
|
+
export function compileRuntimeView(
|
|
3
|
+
presentation: unknown,
|
|
4
|
+
source: string,
|
|
5
|
+
): Promise<RuntimePresentation>;
|
|
6
|
+
|
|
7
|
+
export function getRuntimeViewGuide():Promise<{library:string;schema:unknown;systemPrompt:string}>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { normalizeRuntimePresentation } from "./runtimePresentation.mjs";
|
|
2
|
+
import { normalizeRuntimeView, RESULT_VIEW_LIBRARY } from "./runtimeView.mjs";
|
|
3
|
+
/** OpenUI is an authoring compiler; only its validated static IR crosses the runtime boundary. */
|
|
4
|
+
export async function compileRuntimeView(presentation, source) {
|
|
5
|
+
if (typeof source !== "string" || source.length > 32000)
|
|
6
|
+
throw Error("INVALID_RUNTIME_VIEW");
|
|
7
|
+
const { library, createParser } = await runtimeViewLibrary();
|
|
8
|
+
const parsed = createParser(library.toJSONSchema(), "Stack").parse(source);
|
|
9
|
+
if (
|
|
10
|
+
!parsed.root ||
|
|
11
|
+
parsed.meta.incomplete ||
|
|
12
|
+
parsed.meta.errors.length ||
|
|
13
|
+
parsed.meta.unresolved.length ||
|
|
14
|
+
parsed.meta.orphaned.length ||
|
|
15
|
+
Object.keys(parsed.stateDeclarations).length ||
|
|
16
|
+
parsed.queryStatements.length ||
|
|
17
|
+
parsed.mutationStatements.length
|
|
18
|
+
)
|
|
19
|
+
throw Error("INVALID_RUNTIME_VIEW");
|
|
20
|
+
let count = 0;
|
|
21
|
+
const convert = (n, depth = 0) => {
|
|
22
|
+
if (
|
|
23
|
+
!n ||
|
|
24
|
+
n.type !== "element" ||
|
|
25
|
+
n.partial ||
|
|
26
|
+
n.hasDynamicProps ||
|
|
27
|
+
++count > 61 ||
|
|
28
|
+
depth > 6
|
|
29
|
+
)
|
|
30
|
+
throw Error("INVALID_RUNTIME_VIEW");
|
|
31
|
+
if (n.typeName === "Stack") {
|
|
32
|
+
if (depth) throw Error("INVALID_RUNTIME_VIEW");
|
|
33
|
+
return n.props.children.map((c) => convert(c, depth + 1));
|
|
34
|
+
}
|
|
35
|
+
if (n.typeName === "Section")
|
|
36
|
+
return {
|
|
37
|
+
type: "Section",
|
|
38
|
+
title: n.props.title,
|
|
39
|
+
children: n.props.children.map((c) => convert(c, depth + 1)),
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
type: n.typeName,
|
|
43
|
+
...("block" in n.props ? { block: n.props.block } : {}),
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const p = normalizeRuntimePresentation(presentation);
|
|
47
|
+
return normalizeRuntimePresentation({
|
|
48
|
+
...p,
|
|
49
|
+
view: normalizeRuntimeView(
|
|
50
|
+
{ version: 1, library: RESULT_VIEW_LIBRARY, nodes: convert(parsed.root) },
|
|
51
|
+
p.blocks,
|
|
52
|
+
),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function runtimeViewLibrary() {
|
|
57
|
+
const [{ createLibrary, defineComponent, createParser }, { z }] =
|
|
58
|
+
await Promise.all([import("@openuidev/lang-core"), import("zod")]);
|
|
59
|
+
const leaf = ["Report", "Metrics", "Records", "Comparison"].map((name) =>
|
|
60
|
+
defineComponent({
|
|
61
|
+
name,
|
|
62
|
+
props: z.object({ block: z.number().int().min(0) }),
|
|
63
|
+
component: () => null,
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
const other = ["Sources", "Gaps", "Creator"].map((name) =>
|
|
67
|
+
defineComponent({ name, props: z.object({}), component: () => null }),
|
|
68
|
+
);
|
|
69
|
+
const components = [
|
|
70
|
+
...leaf,
|
|
71
|
+
...other,
|
|
72
|
+
defineComponent({
|
|
73
|
+
name: "Section",
|
|
74
|
+
props: z.object({ title: z.string(), children: z.array(z.any()) }),
|
|
75
|
+
component: () => null,
|
|
76
|
+
}),
|
|
77
|
+
defineComponent({
|
|
78
|
+
name: "Stack",
|
|
79
|
+
props: z.object({ children: z.array(z.any()) }),
|
|
80
|
+
component: () => null,
|
|
81
|
+
}),
|
|
82
|
+
];
|
|
83
|
+
const library = createLibrary({ root: "Stack", components });
|
|
84
|
+
return { library, createParser };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function getRuntimeViewGuide() {
|
|
88
|
+
const { library } = await runtimeViewLibrary();
|
|
89
|
+
return {
|
|
90
|
+
library: RESULT_VIEW_LIBRARY,
|
|
91
|
+
schema: library.toJSONSchema(),
|
|
92
|
+
systemPrompt: library.prompt({
|
|
93
|
+
additionalRules: [
|
|
94
|
+
"Return one root Stack. Reference existing zero-based presentation block indexes; never regenerate task facts. Include every block exactly once. No Query, Mutation, state, functions, actions or arbitrary code. Use Sections to group components. Creator identity comes from the authenticated platform context.",
|
|
95
|
+
],
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RuntimeView } from './runtimeView.mjs';
|
|
1
2
|
export const RESULT_COMPONENTS: readonly ["text", "cards", "table", "metrics"];
|
|
2
3
|
export const RESULT_LAYOUTS: readonly ["report", "comparison", "draft"];
|
|
3
4
|
export type ResultLayout = typeof RESULT_LAYOUTS[number];
|
|
@@ -9,11 +10,12 @@ export type DeliveryDefinition = {
|
|
|
9
10
|
};
|
|
10
11
|
export type ResultBlock =
|
|
11
12
|
| { type: 'text'; title: string; content: string }
|
|
12
|
-
| { type: 'cards'; title: string; items: { title: string; description: string; url?: string }[] }
|
|
13
|
+
| { type: 'cards'; title: string; items: { title: string; description: string; url?: string; citation?: string; detail?: string }[] }
|
|
13
14
|
| { type: 'table'; title: string; columns: string[]; rows: string[][] }
|
|
14
15
|
| { type: 'metrics'; title: string; items: { label: string; value: string }[] };
|
|
15
16
|
export type RuntimePresentation = {
|
|
16
17
|
version: 1; title: string; summary: string; blocks: ResultBlock[];
|
|
18
|
+
view?: RuntimeView;
|
|
17
19
|
sources: { title: string; url: string }[]; incomplete: string[];
|
|
18
20
|
layout?: ResultLayout;
|
|
19
21
|
};
|
package/runtimePresentation.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeRuntimeView } from './runtimeView.mjs';
|
|
1
2
|
// Shared validation for backend and local Agent receipts. No host or network access.
|
|
2
3
|
export const RESULT_COMPONENTS = ['text', 'cards', 'table', 'metrics'];
|
|
3
4
|
export const RESULT_LAYOUTS = ['report', 'comparison', 'draft'];
|
|
@@ -64,7 +65,7 @@ export function normalizeRuntimePresentation(value) {
|
|
|
64
65
|
const url = card.url === undefined ? undefined : resultSourceUrl(card.url);
|
|
65
66
|
if (url === null)
|
|
66
67
|
return fail();
|
|
67
|
-
return { title: text(card.title, 200), description: text(card.description, 4000), ...(url ? { url } : {}) };
|
|
68
|
+
return { title: text(card.title, 200), description: text(card.description, 4000), ...(url ? { url } : {}), ...(card.citation === undefined ? {} : { citation: text(card.citation, 4000) }), ...(card.detail === undefined ? {} : { detail: text(card.detail, 8000) }) };
|
|
68
69
|
}) };
|
|
69
70
|
if (block.type === 'metrics')
|
|
70
71
|
return { type: 'metrics', title, items: array(block.items, 12).map(item => {
|
|
@@ -94,7 +95,7 @@ export function normalizeRuntimePresentation(value) {
|
|
|
94
95
|
if (row.layout !== undefined && !RESULT_LAYOUTS.includes(row.layout)) return fail();
|
|
95
96
|
if (row.layout === 'comparison' && !blocks.some(b => b.type === 'table') || row.layout === 'draft' && !blocks.some(b => b.type === 'text')) return fail();
|
|
96
97
|
const result = { version: 1, title: text(row.title, 200), summary: text(row.summary, 2000), blocks,
|
|
97
|
-
sources: array(row.sources ?? [], 50).map(source), incomplete: array(row.incomplete ?? [], 20).map(item => text(item, 1000)), ...(row.layout === undefined ? {} : { layout: row.layout }) };
|
|
98
|
+
sources: array(row.sources ?? [], 50).map(source), incomplete: array(row.incomplete ?? [], 20).map(item => text(item, 1000)), ...(row.layout === undefined ? {} : { layout: row.layout }), ...(row.view === undefined ? {} : { view: normalizeRuntimeView(row.view, blocks) }) };
|
|
98
99
|
if (new TextEncoder().encode(JSON.stringify(result)).length > 160000)
|
|
99
100
|
return fail();
|
|
100
101
|
return result;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ResultBlock,
|
|
3
|
+
RuntimePresentation,
|
|
4
|
+
} from "./runtimePresentation.mjs";
|
|
5
|
+
export const RESULT_VIEW_LIBRARY: "xiashe.result@1";
|
|
6
|
+
export type ResultViewNode =
|
|
7
|
+
| { type: "Report" | "Metrics" | "Records" | "Comparison"; block: number }
|
|
8
|
+
| { type: "Sources" | "Gaps" | "Creator" }
|
|
9
|
+
| { type: "Section"; title: string; children: ResultViewNode[] };
|
|
10
|
+
export type RuntimeView = {
|
|
11
|
+
version: 1;
|
|
12
|
+
library: typeof RESULT_VIEW_LIBRARY;
|
|
13
|
+
nodes: ResultViewNode[];
|
|
14
|
+
};
|
|
15
|
+
export function normalizeRuntimeView(
|
|
16
|
+
value: unknown,
|
|
17
|
+
blocks: ResultBlock[],
|
|
18
|
+
): RuntimeView;
|
|
19
|
+
export function defaultRuntimeView(p: RuntimePresentation): RuntimeView;
|
|
20
|
+
|
|
21
|
+
export function viewHasCreator(view?: RuntimeView): boolean;
|
package/runtimeView.mjs
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** Portable, bounded view IR. No model code, tools, URLs or credentials are executable. */
|
|
2
|
+
export const RESULT_VIEW_LIBRARY = "xiashe.result@1";
|
|
3
|
+
const kinds = [
|
|
4
|
+
"Report",
|
|
5
|
+
"Metrics",
|
|
6
|
+
"Records",
|
|
7
|
+
"Comparison",
|
|
8
|
+
"Sources",
|
|
9
|
+
"Gaps",
|
|
10
|
+
"Creator",
|
|
11
|
+
"Section",
|
|
12
|
+
];
|
|
13
|
+
export function normalizeRuntimeView(value, blocks) {
|
|
14
|
+
const fail = () => {
|
|
15
|
+
throw Error("INVALID_RUNTIME_VIEW");
|
|
16
|
+
};
|
|
17
|
+
if (
|
|
18
|
+
!value ||
|
|
19
|
+
value.version !== 1 ||
|
|
20
|
+
value.library !== RESULT_VIEW_LIBRARY ||
|
|
21
|
+
!Array.isArray(value.nodes) ||
|
|
22
|
+
!value.nodes.length
|
|
23
|
+
)
|
|
24
|
+
return fail();
|
|
25
|
+
let count = 0;
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
const singleton = new Set();
|
|
28
|
+
const node = (v, depth = 0) => {
|
|
29
|
+
if (
|
|
30
|
+
!v ||
|
|
31
|
+
typeof v !== "object" ||
|
|
32
|
+
++count > 60 ||
|
|
33
|
+
depth > 5 ||
|
|
34
|
+
!kinds.includes(v.type)
|
|
35
|
+
)
|
|
36
|
+
return fail();
|
|
37
|
+
const allowed =
|
|
38
|
+
v.type === "Section"
|
|
39
|
+
? ["type", "title", "children"]
|
|
40
|
+
: ["Report", "Metrics", "Records", "Comparison"].includes(v.type)
|
|
41
|
+
? ["type", "block"]
|
|
42
|
+
: ["type"];
|
|
43
|
+
if (Object.keys(v).some((k) => !allowed.includes(k))) return fail();
|
|
44
|
+
if (v.type === "Section") {
|
|
45
|
+
if (
|
|
46
|
+
typeof v.title !== "string" ||
|
|
47
|
+
!v.title.trim() ||
|
|
48
|
+
v.title.length > 200 ||
|
|
49
|
+
!Array.isArray(v.children) ||
|
|
50
|
+
!v.children.length
|
|
51
|
+
)
|
|
52
|
+
return fail();
|
|
53
|
+
return {
|
|
54
|
+
type: v.type,
|
|
55
|
+
title: v.title.trim(),
|
|
56
|
+
children: v.children.map((c) => node(c, depth + 1)),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (allowed.includes("block")) {
|
|
60
|
+
if (
|
|
61
|
+
!Number.isInteger(v.block) ||
|
|
62
|
+
v.block < 0 ||
|
|
63
|
+
!blocks[v.block] ||
|
|
64
|
+
seen.has(v.block)
|
|
65
|
+
)
|
|
66
|
+
return fail();
|
|
67
|
+
const expected = {
|
|
68
|
+
Report: ["text"],
|
|
69
|
+
Metrics: ["metrics"],
|
|
70
|
+
Records: ["cards", "table"],
|
|
71
|
+
Comparison: ["table"],
|
|
72
|
+
}[v.type];
|
|
73
|
+
if (!expected.includes(blocks[v.block].type)) return fail();
|
|
74
|
+
seen.add(v.block);
|
|
75
|
+
return { type: v.type, block: v.block };
|
|
76
|
+
}
|
|
77
|
+
if (singleton.has(v.type)) return fail();
|
|
78
|
+
singleton.add(v.type);
|
|
79
|
+
return { type: v.type };
|
|
80
|
+
};
|
|
81
|
+
const nodes = value.nodes.map((n) => node(n));
|
|
82
|
+
// Every returned block remains accessible; a generated layout cannot hide evidence.
|
|
83
|
+
if (seen.size !== blocks.length) return fail();
|
|
84
|
+
return { version: 1, library: RESULT_VIEW_LIBRARY, nodes };
|
|
85
|
+
}
|
|
86
|
+
export function defaultRuntimeView(p) {
|
|
87
|
+
const kind = {
|
|
88
|
+
text: "Report",
|
|
89
|
+
metrics: "Metrics",
|
|
90
|
+
cards: "Records",
|
|
91
|
+
table: "Comparison",
|
|
92
|
+
};
|
|
93
|
+
const ordered = p.blocks.map((b, i) => ({ type: kind[b.type], block: i }));
|
|
94
|
+
if (p.layout === "comparison")
|
|
95
|
+
ordered.sort(
|
|
96
|
+
(a, b) =>
|
|
97
|
+
(a.type === "Metrics" ? -2 : a.type === "Comparison" ? -1 : 0) -
|
|
98
|
+
(b.type === "Metrics" ? -2 : b.type === "Comparison" ? -1 : 0),
|
|
99
|
+
);
|
|
100
|
+
if (p.layout === "draft" || p.layout === "report")
|
|
101
|
+
ordered.sort(
|
|
102
|
+
(a, b) => Number(b.type === "Report") - Number(a.type === "Report"),
|
|
103
|
+
);
|
|
104
|
+
return {
|
|
105
|
+
version: 1,
|
|
106
|
+
library: RESULT_VIEW_LIBRARY,
|
|
107
|
+
nodes: [...ordered, { type: "Creator" }],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function viewHasCreator(view) {
|
|
112
|
+
return !!view?.nodes.some(function visit(n) {
|
|
113
|
+
return (
|
|
114
|
+
n.type === "Creator" || (n.type === "Section" && n.children.some(visit))
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
}
|