@parall/cli 1.70.0 → 1.71.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/dist/commands/apps-action-local.d.ts +44 -0
- package/dist/commands/apps-action-local.d.ts.map +1 -0
- package/dist/commands/apps-action-local.js +153 -0
- package/dist/commands/apps-action-stack.d.ts +14 -0
- package/dist/commands/apps-action-stack.d.ts.map +1 -0
- package/dist/commands/apps-action-stack.js +63 -0
- package/dist/commands/apps-actions-sdk.generated.d.ts +2 -0
- package/dist/commands/apps-actions-sdk.generated.d.ts.map +1 -0
- package/dist/commands/apps-actions-sdk.generated.js +3 -0
- package/dist/commands/apps-actions.d.ts +20 -0
- package/dist/commands/apps-actions.d.ts.map +1 -0
- package/dist/commands/apps-actions.js +266 -0
- package/dist/commands/apps-check.d.ts +34 -0
- package/dist/commands/apps-check.d.ts.map +1 -0
- package/dist/commands/apps-check.js +155 -0
- package/dist/commands/apps-dev-page.d.ts +26 -0
- package/dist/commands/apps-dev-page.d.ts.map +1 -0
- package/dist/commands/apps-dev-page.js +259 -0
- package/dist/commands/apps-dev-server.d.ts +42 -0
- package/dist/commands/apps-dev-server.d.ts.map +1 -0
- package/dist/commands/apps-dev-server.js +328 -0
- package/dist/commands/apps-dev.d.ts +8 -0
- package/dist/commands/apps-dev.d.ts.map +1 -0
- package/dist/commands/apps-dev.js +126 -0
- package/dist/commands/apps-local-runner.generated.d.ts +3 -0
- package/dist/commands/apps-local-runner.generated.d.ts.map +1 -0
- package/dist/commands/apps-local-runner.generated.js +4 -0
- package/dist/commands/apps-page-sdk.generated.d.ts +2 -0
- package/dist/commands/apps-page-sdk.generated.d.ts.map +1 -0
- package/dist/commands/apps-page-sdk.generated.js +3 -0
- package/dist/commands/apps-publish.d.ts.map +1 -1
- package/dist/commands/apps-publish.js +6 -0
- package/dist/commands/apps-scaffold-actions.d.ts +11 -0
- package/dist/commands/apps-scaffold-actions.d.ts.map +1 -0
- package/dist/commands/apps-scaffold-actions.js +163 -0
- package/dist/commands/apps-scaffold.d.ts +4 -6
- package/dist/commands/apps-scaffold.d.ts.map +1 -1
- package/dist/commands/apps-scaffold.js +22 -222
- package/dist/commands/apps.d.ts +3 -2
- package/dist/commands/apps.d.ts.map +1 -1
- package/dist/commands/apps.js +9 -2
- package/dist/commands/db-plane.d.ts.map +1 -1
- package/dist/commands/db-plane.js +2 -0
- package/dist/commands/messages.d.ts.map +1 -1
- package/dist/commands/messages.js +6 -11
- package/dist/commands/msteams.d.ts +10 -0
- package/dist/commands/msteams.d.ts.map +1 -0
- package/dist/commands/msteams.js +41 -0
- package/dist/index.js +7 -5
- package/dist/lib/client.d.ts +2 -1
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/mini-app-discovery.d.ts +6 -0
- package/dist/lib/mini-app-discovery.d.ts.map +1 -0
- package/dist/lib/mini-app-discovery.js +32 -0
- package/dist/lib/output.d.ts +3 -1
- package/dist/lib/output.d.ts.map +1 -1
- package/dist/lib/output.js +5 -1
- package/package.json +5 -5
|
@@ -8,6 +8,7 @@ import { createGunzip, createGzip } from 'node:zlib';
|
|
|
8
8
|
import * as tar from 'tar-stream';
|
|
9
9
|
import { resolveCredentials } from '../lib/client.js';
|
|
10
10
|
import { printError, printJson, stripPrllScheme } from '../lib/output.js';
|
|
11
|
+
import { checkActions } from './apps-check.js';
|
|
11
12
|
/** `parall app publish / versions / rollback / pull` (design §7.3): the
|
|
12
13
|
* agent's machine builds, the platform accepts. publish = tar the dist and
|
|
13
14
|
* the source, reserve a seq, PUT both content-addressed tarballs, finalize
|
|
@@ -28,6 +29,11 @@ export function registerAppPublishCommands(app) {
|
|
|
28
29
|
const appId = stripPrllScheme(opts.app);
|
|
29
30
|
const dist = resolve(dir);
|
|
30
31
|
await assertBundleRoot(dist);
|
|
32
|
+
// A module that cannot run fails here rather than at its first call.
|
|
33
|
+
const actions = await checkActions(dist);
|
|
34
|
+
if (actions.module) {
|
|
35
|
+
console.error(`Actions: ${actions.actions.join(', ')} (${actions.module})`);
|
|
36
|
+
}
|
|
31
37
|
const srcDir = resolve(opts.source ?? dir);
|
|
32
38
|
const bundle = await packDirectory(dist, { excludeDefaults: false });
|
|
33
39
|
// Everything after the first archive exists runs inside the cleanup
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** What `parall app init --actions` adds to the page scaffold
|
|
2
|
+
* (docs/engineering-design/mini-app-action-design.md §10.1): the action
|
|
3
|
+
* sources under actions/, the SDK wrapper vendored as
|
|
4
|
+
* actions/parall-actions.ts (ts/miniapp-sdk/src/actions.ts, embedded at
|
|
5
|
+
* build time), a second Vite build that writes dist/_actions/index.js —
|
|
6
|
+
* one unminified ES module with a source map, whose only import is
|
|
7
|
+
* cloudflare:workers — miniflare for `parall app action run --local`, and
|
|
8
|
+
* a page that calls the example action. */
|
|
9
|
+
export declare function withActions(files: Array<[string, string]>): Array<[string, string]>;
|
|
10
|
+
export declare const MINIFLARE_RANGE = "^4.20260415.0";
|
|
11
|
+
//# sourceMappingURL=apps-scaffold-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apps-scaffold-actions.d.ts","sourceRoot":"","sources":["../../src/commands/apps-scaffold-actions.ts"],"names":[],"mappings":"AAEA;;;;;;;2CAO2C;AAC3C,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA4BnF;AAGD,eAAO,MAAM,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { ACTIONS_SDK_SOURCE } from './apps-actions-sdk.generated.js';
|
|
2
|
+
/** What `parall app init --actions` adds to the page scaffold
|
|
3
|
+
* (docs/engineering-design/mini-app-action-design.md §10.1): the action
|
|
4
|
+
* sources under actions/, the SDK wrapper vendored as
|
|
5
|
+
* actions/parall-actions.ts (ts/miniapp-sdk/src/actions.ts, embedded at
|
|
6
|
+
* build time), a second Vite build that writes dist/_actions/index.js —
|
|
7
|
+
* one unminified ES module with a source map, whose only import is
|
|
8
|
+
* cloudflare:workers — miniflare for `parall app action run --local`, and
|
|
9
|
+
* a page that calls the example action. */
|
|
10
|
+
export function withActions(files) {
|
|
11
|
+
const out = files.map(([rel, content]) => {
|
|
12
|
+
if (rel === 'src/App.tsx')
|
|
13
|
+
return [rel, exampleApp(content)];
|
|
14
|
+
if (rel === 'package.json') {
|
|
15
|
+
const pkg = JSON.parse(content);
|
|
16
|
+
pkg.scripts.build = 'vite build && vite build --config vite.actions.config.ts';
|
|
17
|
+
pkg.devDependencies.miniflare = MINIFLARE_RANGE;
|
|
18
|
+
return [rel, `${JSON.stringify(pkg, null, 2)}\n`];
|
|
19
|
+
}
|
|
20
|
+
if (rel === 'public/manifest.json') {
|
|
21
|
+
const manifest = JSON.parse(content);
|
|
22
|
+
manifest.actions = {
|
|
23
|
+
entry: '_actions/index.js',
|
|
24
|
+
functions: { whoami: { kind: 'read' } },
|
|
25
|
+
};
|
|
26
|
+
return [rel, `${JSON.stringify(manifest, null, 2)}\n`];
|
|
27
|
+
}
|
|
28
|
+
if (rel === 'AGENTS.md')
|
|
29
|
+
return [rel, content + ACTIONS_AGENTS_NOTES];
|
|
30
|
+
return [rel, content];
|
|
31
|
+
});
|
|
32
|
+
return [
|
|
33
|
+
...out,
|
|
34
|
+
['actions/index.ts', EXAMPLE_ACTIONS],
|
|
35
|
+
['actions/parall-actions.ts', VENDORED_HEADER + ACTIONS_SDK_SOURCE],
|
|
36
|
+
['actions/cloudflare-workers.d.ts', CLOUDFLARE_WORKERS_SHIM],
|
|
37
|
+
['actions/tsconfig.json', ACTIONS_TSCONFIG],
|
|
38
|
+
['vite.actions.config.ts', VITE_ACTIONS_CONFIG],
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
// workerd with the worker_loaders binding the local runner needs.
|
|
42
|
+
export const MINIFLARE_RANGE = '^4.20260415.0';
|
|
43
|
+
/** The page of an --actions scaffold: the plain page's heading, then the
|
|
44
|
+
* example action read through the bridge, read again on data changes. */
|
|
45
|
+
function exampleApp(plain) {
|
|
46
|
+
const heading = /<h1>.*<\/h1>/.exec(plain)?.[0] ?? '<h1>Mini App</h1>';
|
|
47
|
+
return `import { useCallback, useEffect, useState } from 'react';
|
|
48
|
+
import { parall, type ReadyResult } from './parall';
|
|
49
|
+
|
|
50
|
+
type Whoami = { viewer: string; role?: string; server_time: string };
|
|
51
|
+
|
|
52
|
+
export function App() {
|
|
53
|
+
const [host, setHost] = useState<ReadyResult | null>(null);
|
|
54
|
+
const [me, setMe] = useState<Whoami | null>(null);
|
|
55
|
+
const [error, setError] = useState<string | null>(null);
|
|
56
|
+
|
|
57
|
+
// Actions run on the server as the viewer. Read again whenever the
|
|
58
|
+
// app's Database has new writes.
|
|
59
|
+
const load = useCallback(() => {
|
|
60
|
+
parall
|
|
61
|
+
.action<Whoami>('whoami')
|
|
62
|
+
.then(setMe)
|
|
63
|
+
.catch((err: Error) => setError(err.message));
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
parall
|
|
68
|
+
.ready()
|
|
69
|
+
.then((result) => {
|
|
70
|
+
setHost(result);
|
|
71
|
+
load();
|
|
72
|
+
})
|
|
73
|
+
.catch((err: Error) => setError(err.message));
|
|
74
|
+
return parall.onDataChanged(load);
|
|
75
|
+
}, [load]);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<main style={{ fontFamily: 'system-ui', padding: 24 }}>
|
|
79
|
+
${heading}
|
|
80
|
+
{host ? <p>Hello, {host.viewer.display_name}.</p> : <p>Waiting for the host…</p>}
|
|
81
|
+
{me ? (
|
|
82
|
+
<p>
|
|
83
|
+
The server time is {me.server_time} (your role: {me.role ?? 'member'}).
|
|
84
|
+
</p>
|
|
85
|
+
) : null}
|
|
86
|
+
{error ? <p>Error: {error}</p> : null}
|
|
87
|
+
</main>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
const VENDORED_HEADER = `// Vendored copy of @parall/miniapp-sdk/actions, written by
|
|
93
|
+
// \`parall app init --actions\`. Do not edit; replace it with the npm package
|
|
94
|
+
// once that ships.
|
|
95
|
+
`;
|
|
96
|
+
const EXAMPLE_ACTIONS = `import { ActionError, defineActions } from './parall-actions';
|
|
97
|
+
|
|
98
|
+
// Each action is declared in public/manifest.json under actions.functions
|
|
99
|
+
// (kind read | write, params schema) and implemented here; \`parall app check\`
|
|
100
|
+
// compares the two. The loader looks the entry up by the name ActionRunner.
|
|
101
|
+
export const ActionRunner = defineActions({
|
|
102
|
+
// A read action may only query. ctx.viewer is the caller, as the platform
|
|
103
|
+
// vouches for it: use it for row-level rules.
|
|
104
|
+
async whoami(ctx) {
|
|
105
|
+
const { rows } = await ctx.db.query('SELECT now() AS server_time');
|
|
106
|
+
if (rows.length === 0) throw new ActionError('the database gave no time');
|
|
107
|
+
return { viewer: ctx.viewer.display_name, role: ctx.viewer.role, server_time: rows[0].server_time };
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
`;
|
|
111
|
+
const CLOUDFLARE_WORKERS_SHIM = `// The Workers runtime module the action wrapper imports; the runtime
|
|
112
|
+
// provides it. Declared only as far as parall-actions.ts uses it.
|
|
113
|
+
declare module 'cloudflare:workers' {
|
|
114
|
+
export abstract class WorkerEntrypoint<Env = unknown> {
|
|
115
|
+
protected readonly ctx: unknown;
|
|
116
|
+
protected readonly env: Env;
|
|
117
|
+
constructor(ctx: unknown, env: Env);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
121
|
+
const ACTIONS_TSCONFIG = `${JSON.stringify({
|
|
122
|
+
compilerOptions: {
|
|
123
|
+
target: 'ES2022',
|
|
124
|
+
module: 'ES2022',
|
|
125
|
+
moduleResolution: 'bundler',
|
|
126
|
+
lib: ['ES2022'],
|
|
127
|
+
strict: true,
|
|
128
|
+
noEmit: true,
|
|
129
|
+
skipLibCheck: true,
|
|
130
|
+
},
|
|
131
|
+
include: ['.'],
|
|
132
|
+
}, null, 2)}\n`;
|
|
133
|
+
const VITE_ACTIONS_CONFIG = `import { defineConfig } from 'vite';
|
|
134
|
+
|
|
135
|
+
// The action module: one ES module file in dist/_actions/, built after the
|
|
136
|
+
// page (which empties dist/). Not minified and with a source map, so
|
|
137
|
+
// \`parall app action run\` can map a stack back to actions/*.ts. The only
|
|
138
|
+
// import left is cloudflare:workers, which the Workers runtime provides.
|
|
139
|
+
export default defineConfig({
|
|
140
|
+
publicDir: false,
|
|
141
|
+
build: {
|
|
142
|
+
outDir: 'dist/_actions',
|
|
143
|
+
emptyOutDir: false,
|
|
144
|
+
minify: false,
|
|
145
|
+
sourcemap: true,
|
|
146
|
+
target: 'es2022',
|
|
147
|
+
lib: { entry: 'actions/index.ts', formats: ['es'], fileName: () => 'index.js' },
|
|
148
|
+
rollupOptions: { external: ['cloudflare:workers'] },
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
`;
|
|
152
|
+
const ACTIONS_AGENTS_NOTES = `
|
|
153
|
+
## Actions(服务端函数)
|
|
154
|
+
|
|
155
|
+
- \`actions/index.ts\` 实现,\`public/manifest.json\` 的 \`actions.functions\` 声明(\`kind\`: read 只能查询 / write 可写;\`params\` 是 JSON Schema 子集)。两边要一一对应:\`parall app check dist\` 核对,\`publish\` 也会先跑。
|
|
156
|
+
- \`ctx.viewer\` 是平台担保的调用者,行级规则写在 SQL 里(例:\`WHERE created_by = $1\` 传 \`ctx.viewer.id\`)。能打开 app 的人都能调全部 action。
|
|
157
|
+
- 给调用者看的错误抛 \`ActionError\`;其他异常只有作者与 owner / admin 看得到完整消息与堆栈。写类调用的参数记进全组织可查的调用记录:不要经参数传凭据。
|
|
158
|
+
- 没有网络、没有文件系统;模块级变量在调用者之间共享,不能存调用者的状态。每次 \`ctx.db\` 调用都是一次往返,能合并就合并。
|
|
159
|
+
- 调试:改完 \`pnpm build\` 后 \`parall app action run <app_…> whoami --local\` 在本机 workerd 里跑本地构建,不用先发布;它连的是 app 的真实 Database,**写会真的生效**,\`console.log\` 打到 stderr。出错时堆栈按本地 source map 映射回 \`actions/*.ts\`。要在线上运行时里试,\`parall app publish dist --app <app_…> --preview\` 后 \`parall app action run <app_…> whoami --v <seq>\`。调用记录 \`parall app action log <app_…>\`,执行过的 SQL \`parall app db log --app <app_…>\`(加 \`--invocation <aci_… 或 acd_…>\` 只看一次调用;本机运行的写入版本号为空)。
|
|
160
|
+
- 页面连本地 action:\`parall app dev --dist dist --app <app_…>\`,打开 CLI 打印的地址(带令牌)。页面调的 action 在本机运行,同样**写会真的生效**;右侧列出每次调用、结果与 \`console\` 输出,终端也各打一行。改完重新 \`pnpm build\` 即可,不用重启。
|
|
161
|
+
- 页面用 \`parall.action('whoami')\` 调(\`src/App.tsx\` 是例子)。失败时 \`err.code\` 是服务端的错误码:\`ACTION_FAILED\`(消息是 \`ActionError\` 的原文)、\`INVALID_ACTION_PARAMS\`、\`ACTION_TIMEOUT\`(写类可能已生效)、\`APP_VERSION_CHANGED\`(app 已更新,宿主会提示看的人重新加载);\`HOST_TIMEOUT\` / \`HOST_UNAVAILABLE\` 是没拿到答复,写类先重读再决定是否重试。\`parall.onDataChanged(fn)\` 在 Database 有新写入时调 fn,在里面重读。
|
|
162
|
+
- \`actions/parall-actions.ts\` 是 SDK 的 vendored 副本,不要改。
|
|
163
|
+
`;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
|
-
/** `parall app init
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* vendored into the scaffold (src/parall.ts) until @parall/miniapp-sdk is
|
|
7
|
-
* on npm; it is the same code, @parall/miniapp-sdk stays the SSOT. */
|
|
2
|
+
/** `parall app init`: the fixed scaffold (design §7.4 v1). The scaffold is Vite + React + TS with the bridge wired; Tailwind /
|
|
3
|
+
* shadcn presets arrive with the authoring-skill slice. The bridge is
|
|
4
|
+
* vendored into the scaffold (src/parall.ts, ts/miniapp-sdk/src/index.ts
|
|
5
|
+
* embedded at build time) until @parall/miniapp-sdk is on npm. */
|
|
8
6
|
export declare function registerAppScaffoldCommands(app: Command): void;
|
|
9
7
|
//# sourceMappingURL=apps-scaffold.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps-scaffold.d.ts","sourceRoot":"","sources":["../../src/commands/apps-scaffold.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apps-scaffold.d.ts","sourceRoot":"","sources":["../../src/commands/apps-scaffold.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC;;;kEAGkE;AAClE,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,QAsCvD"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
|
-
import {
|
|
3
|
-
import { extname, join, normalize, resolve, sep } from 'node:path';
|
|
2
|
+
import { join, resolve, sep } from 'node:path';
|
|
4
3
|
import { printError } from '../lib/output.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* shadcn presets arrive with the authoring-skill slice. The
|
|
9
|
-
* vendored into the scaffold (src/parall.ts
|
|
10
|
-
*
|
|
4
|
+
import { PAGE_SDK_SOURCE } from './apps-page-sdk.generated.js';
|
|
5
|
+
import { withActions } from './apps-scaffold-actions.js';
|
|
6
|
+
/** `parall app init`: the fixed scaffold (design §7.4 v1). The scaffold is Vite + React + TS with the bridge wired; Tailwind /
|
|
7
|
+
* shadcn presets arrive with the authoring-skill slice. The bridge is
|
|
8
|
+
* vendored into the scaffold (src/parall.ts, ts/miniapp-sdk/src/index.ts
|
|
9
|
+
* embedded at build time) until @parall/miniapp-sdk is on npm. */
|
|
11
10
|
export function registerAppScaffoldCommands(app) {
|
|
12
11
|
app
|
|
13
12
|
.command('init')
|
|
14
|
-
.description('Scaffold a new Mini App project (Vite + React + TS, bridge
|
|
13
|
+
.description('Scaffold a new Mini App project (Vite + React + TS, bridge wired)')
|
|
15
14
|
.argument('<dir>', 'Directory to create (must be empty or absent)')
|
|
16
|
-
.
|
|
15
|
+
.option('--actions', 'Also scaffold server-side actions (actions/ → dist/_actions/index.js)')
|
|
16
|
+
.action(async (dir, opts) => {
|
|
17
17
|
try {
|
|
18
18
|
const out = resolve(dir);
|
|
19
19
|
await fs.mkdir(out, { recursive: true });
|
|
@@ -21,7 +21,8 @@ export function registerAppScaffoldCommands(app) {
|
|
|
21
21
|
throw new Error(`${out} is not empty`);
|
|
22
22
|
}
|
|
23
23
|
const name = out.split(sep).pop() ?? 'mini-app';
|
|
24
|
-
|
|
24
|
+
const files = opts.actions ? withActions(scaffoldFiles(name)) : scaffoldFiles(name);
|
|
25
|
+
for (const [rel, content] of files) {
|
|
25
26
|
const target = join(out, rel);
|
|
26
27
|
await fs.mkdir(resolve(target, '..'), { recursive: true });
|
|
27
28
|
await fs.writeFile(target, content);
|
|
@@ -31,121 +32,18 @@ export function registerAppScaffoldCommands(app) {
|
|
|
31
32
|
'',
|
|
32
33
|
'Next steps:',
|
|
33
34
|
` cd ${dir} && pnpm install && pnpm build`,
|
|
35
|
+
...(opts.actions ? [' parall app check dist # manifest ↔ actions/'] : []),
|
|
34
36
|
` parall app create --name "${name}"`,
|
|
35
37
|
` parall app publish dist --app <app_…> --source .`,
|
|
36
|
-
|
|
38
|
+
opts.actions
|
|
39
|
+
? ` parall app dev --dist dist --app <app_…> # the page calls its actions on this machine`
|
|
40
|
+
: ` parall app dev --dist dist # look at it locally first`,
|
|
37
41
|
].join('\n'));
|
|
38
42
|
}
|
|
39
43
|
catch (err) {
|
|
40
44
|
printError(err);
|
|
41
45
|
}
|
|
42
46
|
});
|
|
43
|
-
app
|
|
44
|
-
.command('dev')
|
|
45
|
-
.description('Serve a built bundle under a local host page that speaks the bridge shell')
|
|
46
|
-
.option('--dist <dir>', 'The built bundle directory', 'dist')
|
|
47
|
-
.option('--port <n>', 'Port to listen on', '5180')
|
|
48
|
-
.action(async (opts) => {
|
|
49
|
-
try {
|
|
50
|
-
const dist = resolve(opts.dist);
|
|
51
|
-
await fs.access(join(dist, 'index.html'));
|
|
52
|
-
const port = Number(opts.port);
|
|
53
|
-
const server = createServer((req, res) => {
|
|
54
|
-
void handleDevRequest(dist, req.url ?? '/', res);
|
|
55
|
-
});
|
|
56
|
-
// Loopback only: this serves the app's build directory and must not
|
|
57
|
-
// be reachable from the local network. A bind failure (port in use)
|
|
58
|
-
// arrives as an 'error' event, not a throw — it has to reach the
|
|
59
|
-
// catch below instead of crashing the CLI.
|
|
60
|
-
await new Promise((resolveListen, rejectListen) => {
|
|
61
|
-
server.once('error', rejectListen);
|
|
62
|
-
server.listen(port, '127.0.0.1', () => {
|
|
63
|
-
server.off('error', rejectListen);
|
|
64
|
-
resolveListen();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
console.error(`Mini App dev host: http://127.0.0.1:${port}/ (serving ${dist})`);
|
|
68
|
-
console.error('The host page answers parall.ready() with a local dev viewer; Ctrl-C to stop.');
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
printError(err);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const devContentTypes = {
|
|
76
|
-
'.html': 'text/html; charset=utf-8',
|
|
77
|
-
'.js': 'text/javascript; charset=utf-8',
|
|
78
|
-
'.mjs': 'text/javascript; charset=utf-8',
|
|
79
|
-
'.css': 'text/css; charset=utf-8',
|
|
80
|
-
'.json': 'application/json',
|
|
81
|
-
'.svg': 'image/svg+xml',
|
|
82
|
-
'.png': 'image/png',
|
|
83
|
-
'.jpg': 'image/jpeg',
|
|
84
|
-
'.ico': 'image/x-icon',
|
|
85
|
-
'.map': 'application/json',
|
|
86
|
-
'.woff2': 'font/woff2',
|
|
87
|
-
};
|
|
88
|
-
async function handleDevRequest(dist, url, res) {
|
|
89
|
-
try {
|
|
90
|
-
const pathname = decodeURIComponent(new URL(url, 'http://localhost').pathname);
|
|
91
|
-
if (pathname === '/' || pathname === '/index.html') {
|
|
92
|
-
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
93
|
-
res.end(devHostPage());
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (pathname.startsWith('/app/')) {
|
|
97
|
-
const rel = normalize(pathname.slice('/app/'.length));
|
|
98
|
-
if (rel.startsWith('..') || rel.includes(`..${sep}`)) {
|
|
99
|
-
res.writeHead(404).end();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const file = join(dist, rel === '' || rel === '.' ? 'index.html' : rel);
|
|
103
|
-
const body = await fs.readFile(file);
|
|
104
|
-
res.writeHead(200, {
|
|
105
|
-
'Content-Type': devContentTypes[extname(file).toLowerCase()] ?? 'application/octet-stream',
|
|
106
|
-
});
|
|
107
|
-
res.end(body);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
res.writeHead(404).end('not found');
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
res.writeHead(404).end('not found');
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/** The local host page: the host side of the bridge shell — answers ready
|
|
117
|
-
* with a dev viewer, relays resize, logs everything else. The same
|
|
118
|
-
* request/response protocol the real hosts speak (§6.3, shell subset). */
|
|
119
|
-
function devHostPage() {
|
|
120
|
-
return `<!doctype html>
|
|
121
|
-
<html>
|
|
122
|
-
<head><meta charset="utf-8"><title>Mini App dev host</title>
|
|
123
|
-
<style>body{margin:0;font-family:system-ui}header{padding:8px 12px;background:#111;color:#eee;font-size:13px}iframe{border:0;width:100%;height:calc(100vh - 37px)}</style>
|
|
124
|
-
</head>
|
|
125
|
-
<body>
|
|
126
|
-
<header>parall app dev — local host (bridge shell: ready / resize / route.changed)</header>
|
|
127
|
-
<iframe id="app" sandbox="allow-scripts allow-same-origin allow-downloads" src="/app/index.html"></iframe>
|
|
128
|
-
<script>
|
|
129
|
-
const frame = document.getElementById('app');
|
|
130
|
-
window.addEventListener('message', (event) => {
|
|
131
|
-
if (event.source !== frame.contentWindow) return;
|
|
132
|
-
const msg = event.data;
|
|
133
|
-
if (!msg || msg.parall !== 'v1' || typeof msg.id !== 'number') return;
|
|
134
|
-
if (msg.method === 'ready') {
|
|
135
|
-
frame.contentWindow.postMessage({ parall: 'v1', id: msg.id, result: {
|
|
136
|
-
viewer: { id: 'usr_dev', display_name: 'Dev Viewer', is_agent: false },
|
|
137
|
-
app: { id: 'app_dev', name: 'local dev', version_seq: 0 },
|
|
138
|
-
route: location.hash.slice(1) || '',
|
|
139
|
-
}}, '*');
|
|
140
|
-
} else if (msg.method === 'resize') {
|
|
141
|
-
frame.contentWindow.postMessage({ parall: 'v1', id: msg.id, result: {} }, '*');
|
|
142
|
-
} else {
|
|
143
|
-
frame.contentWindow.postMessage({ parall: 'v1', id: msg.id, error: { code: 'NOT_GRANTED', message: msg.method + ' is not part of the shell bridge' } }, '*');
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
</script>
|
|
147
|
-
</body>
|
|
148
|
-
</html>`;
|
|
149
47
|
}
|
|
150
48
|
function scaffoldFiles(name) {
|
|
151
49
|
return [
|
|
@@ -261,119 +159,21 @@ export function App() {
|
|
|
261
159
|
}
|
|
262
160
|
`,
|
|
263
161
|
],
|
|
264
|
-
['src/parall.ts',
|
|
162
|
+
['src/parall.ts', PAGE_VENDORED_HEADER + PAGE_SDK_SOURCE],
|
|
265
163
|
[
|
|
266
164
|
'AGENTS.md',
|
|
267
165
|
`# ${name} — Mini App 约定
|
|
268
166
|
|
|
269
167
|
- 这是一个 Parall Mini App:纯静态 bundle,所有脚本 / 样式 / 字体都必须打进 dist(app origin 的 CSP 只放 'self',任何外部 URL 引用会在 publish 验收时被拒)。
|
|
270
168
|
- \`public/manifest.json\` 随构建进入 dist 根部;entry 固定 index.html。
|
|
271
|
-
-
|
|
272
|
-
- 流程:\`pnpm build\` → \`parall app publish dist --app <app_…> --source .\` → 在 Parall 里打开;先 \`parall app dev --dist dist\`
|
|
273
|
-
- \`src/parall.ts\` 是 @parall/miniapp-sdk 的 vendored 副本(npm
|
|
169
|
+
- 页面的数据只经 action:\`parall.action(name, params)\` 以看页面的人的身份调本 app 的服务端 action(\`parall app init --actions\` 生成 actions/),\`parall.onDataChanged(fn)\` 在 Database 有新写入时通知页面重新读。桥上没有 SQL、files、clip 方法。
|
|
170
|
+
- 流程:\`pnpm build\` → \`parall app publish dist --app <app_…> --source .\` → 在 Parall 里打开;先 \`parall app dev --dist dist\` 本地看一眼(不带 \`--app\` 时只托管页面、不跑 action)。
|
|
171
|
+
- \`src/parall.ts\` 是 @parall/miniapp-sdk 的 vendored 副本(npm 发布前);不要改。
|
|
274
172
|
`,
|
|
275
173
|
],
|
|
276
174
|
['.gitignore', 'node_modules\ndist\n'],
|
|
277
175
|
];
|
|
278
176
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
function vendoredShell() {
|
|
282
|
-
return `// Vendored copy of @parall/miniapp-sdk (bridge SHELL: ready / resize /
|
|
283
|
-
// events; deliberately no data APIs). Replace with the npm package once it
|
|
284
|
-
// ships; do not add capabilities here.
|
|
285
|
-
|
|
286
|
-
export interface ViewerSummary {
|
|
287
|
-
id: string;
|
|
288
|
-
display_name: string;
|
|
289
|
-
is_agent: boolean;
|
|
290
|
-
role?: string;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export interface AppSummary {
|
|
294
|
-
id: string;
|
|
295
|
-
name: string;
|
|
296
|
-
version_seq: number;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
export interface ReadyResult {
|
|
300
|
-
viewer: ViewerSummary;
|
|
301
|
-
app: AppSummary;
|
|
302
|
-
route: string;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
export type HostEvent =
|
|
306
|
-
| { event: 'route.changed'; data: { route: string } }
|
|
307
|
-
| { event: 'viewer.changed'; data: { viewer: ViewerSummary } };
|
|
308
|
-
|
|
309
|
-
type Pending = { resolve: (v: unknown) => void; reject: (e: Error) => void; timer: ReturnType<typeof setTimeout> };
|
|
310
|
-
|
|
311
|
-
const PROTOCOL = 'v1';
|
|
312
|
-
|
|
313
|
-
class MiniAppBridge {
|
|
314
|
-
private nextId = 1;
|
|
315
|
-
private pending = new Map<number, Pending>();
|
|
316
|
-
private listeners = new Set<(e: HostEvent) => void>();
|
|
317
|
-
private hostOrigin: string | null = null;
|
|
318
|
-
private started = false;
|
|
319
|
-
|
|
320
|
-
private start(): void {
|
|
321
|
-
if (this.started) return;
|
|
322
|
-
this.started = true;
|
|
323
|
-
window.addEventListener('message', (event: MessageEvent) => {
|
|
324
|
-
if (event.source !== window.parent) return;
|
|
325
|
-
if (this.hostOrigin !== null && event.origin !== this.hostOrigin) return;
|
|
326
|
-
const msg = event.data as Record<string, unknown> | null;
|
|
327
|
-
if (!msg || msg.parall !== PROTOCOL) return;
|
|
328
|
-
if (typeof msg.id === 'number') {
|
|
329
|
-
const pending = this.pending.get(msg.id);
|
|
330
|
-
if (!pending) return;
|
|
331
|
-
this.pending.delete(msg.id);
|
|
332
|
-
clearTimeout(pending.timer);
|
|
333
|
-
if (this.hostOrigin === null) this.hostOrigin = event.origin;
|
|
334
|
-
if (msg.error) {
|
|
335
|
-
const err = msg.error as { code: string; message: string };
|
|
336
|
-
pending.reject(Object.assign(new Error(err.message), { code: err.code }));
|
|
337
|
-
} else {
|
|
338
|
-
pending.resolve(msg.result);
|
|
339
|
-
}
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
if (typeof msg.event === 'string') {
|
|
343
|
-
for (const fn of this.listeners) fn(msg as unknown as HostEvent);
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
private call<T>(method: string, params?: unknown): Promise<T> {
|
|
349
|
-
this.start();
|
|
350
|
-
const id = this.nextId++;
|
|
351
|
-
return new Promise<T>((resolve, reject) => {
|
|
352
|
-
const timer = setTimeout(() => {
|
|
353
|
-
if (this.pending.delete(id)) {
|
|
354
|
-
reject(Object.assign(new Error(method + ' timed out waiting for the host'), { code: 'HOST_TIMEOUT' }));
|
|
355
|
-
}
|
|
356
|
-
}, 10_000);
|
|
357
|
-
this.pending.set(id, { resolve: resolve as (v: unknown) => void, reject, timer });
|
|
358
|
-
window.parent.postMessage({ parall: PROTOCOL, id, method, params }, '*');
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
ready(): Promise<ReadyResult> {
|
|
363
|
-
return this.call<ReadyResult>('ready');
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
resize(height: number): void {
|
|
367
|
-
void this.call('resize', { height }).catch(() => {});
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
onEvent(fn: (e: HostEvent) => void): () => void {
|
|
371
|
-
this.start();
|
|
372
|
-
this.listeners.add(fn);
|
|
373
|
-
return () => this.listeners.delete(fn);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
export const parall = new MiniAppBridge();
|
|
177
|
+
const PAGE_VENDORED_HEADER = `// Vendored copy of @parall/miniapp-sdk, written by \`parall app init\`. Do
|
|
178
|
+
// not edit; replace it with the npm package once that ships.
|
|
378
179
|
`;
|
|
379
|
-
}
|
package/dist/commands/apps.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import type { Command } from 'commander';
|
|
|
4
4
|
* opens every app; its authors manage it. This file manages the entity and
|
|
5
5
|
* its author roster; `app db …` (apps-db.ts) is the app alias of the data
|
|
6
6
|
* plane, `parall db …` (dbs.ts) the Database itself; publish / versions /
|
|
7
|
-
* rollback / pull live in apps-publish.ts
|
|
8
|
-
* in apps-scaffold.ts
|
|
7
|
+
* rollback / pull live in apps-publish.ts, the scaffold + local dev host
|
|
8
|
+
* in apps-scaffold.ts, and the app's actions in apps-actions.ts (run, list,
|
|
9
|
+
* log) and apps-check.ts (the pre-publish module check). Every command answers 404 while the deployment has
|
|
9
10
|
* cap:mini-apps off and 403 MINI_APPS_UNAVAILABLE for an org without the
|
|
10
11
|
* mini-apps flag. */
|
|
11
12
|
export declare function registerAppCommands(program: Command): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../src/commands/apps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../src/commands/apps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC;;;;;;;;;qBASqB;AACrB,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,QA6KnD"}
|
package/dist/commands/apps.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { resolveCredentials } from '../lib/client.js';
|
|
2
2
|
import { printError, printJson, printRefHint, stripPrllScheme } from '../lib/output.js';
|
|
3
|
+
import { registerAppActionCommands } from './apps-actions.js';
|
|
4
|
+
import { registerAppCheckCommand } from './apps-check.js';
|
|
3
5
|
import { registerAppDBCommands } from './apps-db.js';
|
|
6
|
+
import { registerAppDevCommand } from './apps-dev.js';
|
|
4
7
|
import { registerAppPublishCommands } from './apps-publish.js';
|
|
5
8
|
import { registerAppScaffoldCommands } from './apps-scaffold.js';
|
|
6
9
|
/** Mini App entity: an agent-authored app of the organization, attached to
|
|
@@ -8,8 +11,9 @@ import { registerAppScaffoldCommands } from './apps-scaffold.js';
|
|
|
8
11
|
* opens every app; its authors manage it. This file manages the entity and
|
|
9
12
|
* its author roster; `app db …` (apps-db.ts) is the app alias of the data
|
|
10
13
|
* plane, `parall db …` (dbs.ts) the Database itself; publish / versions /
|
|
11
|
-
* rollback / pull live in apps-publish.ts
|
|
12
|
-
* in apps-scaffold.ts
|
|
14
|
+
* rollback / pull live in apps-publish.ts, the scaffold + local dev host
|
|
15
|
+
* in apps-scaffold.ts, and the app's actions in apps-actions.ts (run, list,
|
|
16
|
+
* log) and apps-check.ts (the pre-publish module check). Every command answers 404 while the deployment has
|
|
13
17
|
* cap:mini-apps off and 403 MINI_APPS_UNAVAILABLE for an org without the
|
|
14
18
|
* mini-apps flag. */
|
|
15
19
|
export function registerAppCommands(program) {
|
|
@@ -19,6 +23,9 @@ export function registerAppCommands(program) {
|
|
|
19
23
|
registerAppDBCommands(app);
|
|
20
24
|
registerAppPublishCommands(app);
|
|
21
25
|
registerAppScaffoldCommands(app);
|
|
26
|
+
registerAppDevCommand(app);
|
|
27
|
+
registerAppCheckCommand(app);
|
|
28
|
+
registerAppActionCommands(app);
|
|
22
29
|
app
|
|
23
30
|
.command('list')
|
|
24
31
|
.description("List the organization's Mini Apps")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-plane.d.ts","sourceRoot":"","sources":["../../src/commands/db-plane.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAUV,eAAe,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEjD;4EAC4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;gEACgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB;qBACiB;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACvF;AAED;;;;;;;;;+BAS+B;AAC/B,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"db-plane.d.ts","sourceRoot":"","sources":["../../src/commands/db-plane.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAUV,eAAe,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEjD;4EAC4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;gEACgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB;qBACiB;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACvF;AAED;;;;;;;;;+BAS+B;AAC/B,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,QA2JlF;AAgED;;;4BAG4B;AAC5B,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,eAAe,EAAE,GAAG,SAAS,CASpF"}
|
|
@@ -112,12 +112,14 @@ export function registerDataPlaneCommands(group, binding) {
|
|
|
112
112
|
.description('SQL log: execs with actor, app, role, rows, data_seq and errors'))
|
|
113
113
|
.option('--limit <n>', 'Entries to return (default 50, max 200)')
|
|
114
114
|
.option('--before <rfc3339>', 'Entries created before this instant')
|
|
115
|
+
.option('--invocation <aci_id>', "Only one action invocation's statements")
|
|
115
116
|
.action(async (opts) => {
|
|
116
117
|
try {
|
|
117
118
|
const ctx = resolveCredentials();
|
|
118
119
|
printJson(await log(ctx, await binding.resolve(ctx, opts), {
|
|
119
120
|
limit: opts.limit ? Number(opts.limit) : undefined,
|
|
120
121
|
before: opts.before,
|
|
122
|
+
invocation_id: opts.invocation,
|
|
121
123
|
}));
|
|
122
124
|
}
|
|
123
125
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/commands/messages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5C,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GACtD;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CASzC;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/commands/messages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC5C,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GACtD;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CASzC;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QA8TvD"}
|
|
@@ -179,17 +179,12 @@ export function registerMessageCommands(program) {
|
|
|
179
179
|
};
|
|
180
180
|
if (attachmentIds)
|
|
181
181
|
req.attachment_ids = attachmentIds;
|
|
182
|
-
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
|
|
188
|
-
ctx.dispatchSourceId &&
|
|
189
|
-
ctx.threadRootId &&
|
|
190
|
-
chatId === ctx.chatId) {
|
|
191
|
-
threadRootId = ctx.threadRootId;
|
|
192
|
-
}
|
|
182
|
+
// Placement is the command alone: no --thread-root-id means top level,
|
|
183
|
+
// on every runtime. The dispatch context never picks the thread — a
|
|
184
|
+
// parel turn can fold a chat's top-level and thread messages while
|
|
185
|
+
// its env stays the turn-opening one, so a context default would
|
|
186
|
+
// misroute the folded ones (and leave no way to post top level).
|
|
187
|
+
const threadRootId = opts.threadRootId !== undefined ? stripPrllScheme(opts.threadRootId) : undefined;
|
|
193
188
|
if (threadRootId !== undefined)
|
|
194
189
|
req.thread_root_id = threadRootId;
|
|
195
190
|
if (opts.reply === false)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* `parall msteams …` — the per-vendor platform verb for Microsoft Teams, a
|
|
4
|
+
* channel whose vendor ships no agent-grade CLI (tier B in the multi-channel
|
|
5
|
+
* architecture). The agent sends as its bound bot; the bot's Microsoft
|
|
6
|
+
* credentials never reach the runtime — api-server performs the call.
|
|
7
|
+
* Design: docs/engineering-design/teams-channel-design.md §4.
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerMSTeamsCommands(program: Command): void;
|
|
10
|
+
//# sourceMappingURL=msteams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msteams.d.ts","sourceRoot":"","sources":["../../src/commands/msteams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QA2CvD"}
|