@yaks/cli 0.0.0-stage → 0.2.36
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 +202 -0
- package/README.md +1059 -2
- package/_dist/account-forward.d.ts +12 -0
- package/_dist/account-forward.d.ts.map +1 -0
- package/_dist/accounts.d.ts +23 -0
- package/_dist/accounts.d.ts.map +1 -0
- package/_dist/answer.d.ts +88 -0
- package/_dist/answer.d.ts.map +1 -0
- package/_dist/apply.d.ts +17 -0
- package/_dist/apply.d.ts.map +1 -0
- package/_dist/args.d.ts +86 -0
- package/_dist/args.d.ts.map +1 -0
- package/_dist/commands.d.ts +15 -0
- package/_dist/commands.d.ts.map +1 -0
- package/_dist/complete.d.ts +15 -0
- package/_dist/complete.d.ts.map +1 -0
- package/_dist/config.d.ts +37 -0
- package/_dist/config.d.ts.map +1 -0
- package/_dist/dependencies.d.ts +6 -0
- package/_dist/dependencies.d.ts.map +1 -0
- package/_dist/facets.d.ts +71 -0
- package/_dist/facets.d.ts.map +1 -0
- package/_dist/grammar.d.ts +5 -0
- package/_dist/grammar.d.ts.map +1 -0
- package/_dist/host.d.ts +164 -0
- package/_dist/host.d.ts.map +1 -0
- package/_dist/install.d.ts +43 -0
- package/_dist/install.d.ts.map +1 -0
- package/_dist/main.d.ts +16 -0
- package/_dist/main.d.ts.map +1 -0
- package/_dist/memo.d.ts +60 -0
- package/_dist/memo.d.ts.map +1 -0
- package/_dist/mod.d.ts +46 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/page.d.ts +73 -0
- package/_dist/page.d.ts.map +1 -0
- package/_dist/platform.d.ts +27 -0
- package/_dist/platform.d.ts.map +1 -0
- package/_dist/reader.d.ts +10 -0
- package/_dist/reader.d.ts.map +1 -0
- package/_dist/release.d.ts +48 -0
- package/_dist/release.d.ts.map +1 -0
- package/_dist/remote.d.ts +13 -0
- package/_dist/remote.d.ts.map +1 -0
- package/_dist/reported.d.ts +11 -0
- package/_dist/reported.d.ts.map +1 -0
- package/_dist/roles.d.ts +2 -0
- package/_dist/roles.d.ts.map +1 -0
- package/_dist/roster.d.ts +41 -0
- package/_dist/roster.d.ts.map +1 -0
- package/_dist/rpc.d.ts +29 -0
- package/_dist/rpc.d.ts.map +1 -0
- package/_dist/run.d.ts +164 -0
- package/_dist/run.d.ts.map +1 -0
- package/_dist/runtime.d.ts +4 -0
- package/_dist/runtime.d.ts.map +1 -0
- package/_dist/searching.d.ts +7 -0
- package/_dist/searching.d.ts.map +1 -0
- package/_dist/show.d.ts +22 -0
- package/_dist/show.d.ts.map +1 -0
- package/_dist/store.d.ts +25 -0
- package/_dist/store.d.ts.map +1 -0
- package/_dist/terminal.d.ts +17 -0
- package/_dist/terminal.d.ts.map +1 -0
- package/_dist/tool.d.ts +55 -0
- package/_dist/tool.d.ts.map +1 -0
- package/_dist/tty.d.ts +3 -0
- package/_dist/tty.d.ts.map +1 -0
- package/_dist/vault.d.ts +9 -0
- package/_dist/vault.d.ts.map +1 -0
- package/_dist/words.d.ts +11 -0
- package/_dist/words.d.ts.map +1 -0
- package/_dist/yak.d.ts +10 -0
- package/_dist/yak.d.ts.map +1 -0
- package/account-forward.js +40 -0
- package/account-forward.js.map +1 -0
- package/account-forward.ts +50 -0
- package/accounts.js +162 -0
- package/accounts.js.map +1 -0
- package/accounts.ts +228 -0
- package/answer.js +394 -0
- package/answer.js.map +1 -0
- package/answer.ts +569 -0
- package/apply.js +49 -0
- package/apply.js.map +1 -0
- package/apply.ts +54 -0
- package/args.js +420 -0
- package/args.js.map +1 -0
- package/args.ts +494 -0
- package/code.js +209 -0
- package/code.js.map +1 -0
- package/code.ts +227 -0
- package/commands.js +131 -0
- package/commands.js.map +1 -0
- package/commands.ts +142 -0
- package/complete.js +104 -0
- package/complete.js.map +1 -0
- package/complete.ts +152 -0
- package/config.js +125 -0
- package/config.js.map +1 -0
- package/config.ts +180 -0
- package/declarations.js +67 -0
- package/declarations.js.map +1 -0
- package/declarations.ts +84 -0
- package/deno.json +1 -0
- package/dependencies.js +126 -0
- package/dependencies.js.map +1 -0
- package/dependencies.ts +141 -0
- package/derive.js +102 -0
- package/derive.js.map +1 -0
- package/derive.ts +125 -0
- package/drain.js +83 -0
- package/drain.js.map +1 -0
- package/drain.ts +115 -0
- package/duties.ts +17 -0
- package/exports.json +1486 -0
- package/external.js +373 -0
- package/external.js.map +1 -0
- package/external.ts +435 -0
- package/facets.js +214 -0
- package/facets.js.map +1 -0
- package/facets.ts +232 -0
- package/feedback.js +54 -0
- package/feedback.js.map +1 -0
- package/feedback.ts +57 -0
- package/files.js +84 -0
- package/files.js.map +1 -0
- package/files.ts +112 -0
- package/get_starts.js +31 -0
- package/get_starts.js.map +1 -0
- package/get_starts.ts +34 -0
- package/git-credential.js +79 -0
- package/git-credential.js.map +1 -0
- package/git-credential.ts +77 -0
- package/grammar.js +4 -0
- package/grammar.js.map +1 -0
- package/grammar.ts +5 -0
- package/held.js +51 -0
- package/held.js.map +1 -0
- package/held.ts +66 -0
- package/host.js +1174 -0
- package/host.js.map +1 -0
- package/host.ts +1343 -0
- package/init.js +138 -0
- package/init.js.map +1 -0
- package/init.ts +139 -0
- package/install.js +216 -0
- package/install.js.map +1 -0
- package/install.ts +223 -0
- package/lifetime.js +56 -0
- package/lifetime.js.map +1 -0
- package/lifetime.ts +66 -0
- package/local-page.ts +114 -0
- package/local.js +417 -0
- package/local.js.map +1 -0
- package/local.ts +537 -0
- package/lockfile.js +20 -0
- package/lockfile.js.map +1 -0
- package/lockfile.ts +32 -0
- package/machines.js +33 -0
- package/machines.js.map +1 -0
- package/machines.ts +51 -0
- package/made/4f855610bdabcd736100d34e4e467ea5.json +1 -0
- package/main.js +534 -0
- package/main.js.map +1 -0
- package/main.ts +547 -0
- package/mcp.js +108 -0
- package/mcp.js.map +1 -0
- package/mcp.ts +113 -0
- package/member.js +103 -0
- package/member.js.map +1 -0
- package/member.ts +133 -0
- package/memo.js +503 -0
- package/memo.js.map +1 -0
- package/memo.ts +634 -0
- package/mod.js +46 -0
- package/mod.js.map +1 -0
- package/mod.ts +99 -0
- package/operations.js +53 -0
- package/operations.js.map +1 -0
- package/operations.ts +68 -0
- package/package.json +115 -4
- package/page.js +211 -0
- package/page.js.map +1 -0
- package/page.ts +308 -0
- package/parser.js +45 -0
- package/parser.js.map +1 -0
- package/parser.ts +77 -0
- package/people-search.js +112 -0
- package/people-search.js.map +1 -0
- package/people-search.ts +162 -0
- package/platform.js +184 -0
- package/platform.js.map +1 -0
- package/platform.ts +224 -0
- package/platform_effects.js +5 -0
- package/platform_effects.js.map +1 -0
- package/platform_effects.ts +13 -0
- package/prepare.js +40 -0
- package/prepare.js.map +1 -0
- package/prepare.ts +46 -0
- package/read_activity.js +54 -0
- package/read_activity.js.map +1 -0
- package/read_activity.ts +61 -0
- package/read_thread.js +387 -0
- package/read_thread.js.map +1 -0
- package/read_thread.ts +506 -0
- package/read_worker.ts +164 -0
- package/reader.js +48 -0
- package/reader.js.map +1 -0
- package/reader.ts +57 -0
- package/release.js +82 -0
- package/release.js.map +1 -0
- package/release.json +127 -0
- package/release.ts +98 -0
- package/remote-page.ts +70 -0
- package/remote.js +96 -0
- package/remote.js.map +1 -0
- package/remote.ts +153 -0
- package/report.js +83 -0
- package/report.js.map +1 -0
- package/report.ts +101 -0
- package/reported.js +32 -0
- package/reported.js.map +1 -0
- package/reported.ts +38 -0
- package/restart.js +349 -0
- package/restart.js.map +1 -0
- package/restart.ts +478 -0
- package/restore.js +32 -0
- package/restore.js.map +1 -0
- package/restore.ts +38 -0
- package/roles.js +32 -0
- package/roles.js.map +1 -0
- package/roles.ts +49 -0
- package/roster.js +65 -0
- package/roster.js.map +1 -0
- package/roster.ts +84 -0
- package/rpc.js +113 -0
- package/rpc.js.map +1 -0
- package/rpc.ts +159 -0
- package/run.js +533 -0
- package/run.js.map +1 -0
- package/run.ts +741 -0
- package/runtime.js +381 -0
- package/runtime.js.map +1 -0
- package/runtime.ts +433 -0
- package/sandboxes.js +26 -0
- package/sandboxes.js.map +1 -0
- package/sandboxes.ts +30 -0
- package/searching.js +33 -0
- package/searching.js.map +1 -0
- package/searching.ts +50 -0
- package/show.js +109 -0
- package/show.js.map +1 -0
- package/show.ts +144 -0
- package/shown.js +13 -0
- package/shown.js.map +1 -0
- package/shown.ts +44 -0
- package/stall.js +90 -0
- package/stall.js.map +1 -0
- package/stall.ts +156 -0
- package/stall_profile.js +113 -0
- package/stall_profile.js.map +1 -0
- package/stall_profile.ts +142 -0
- package/stall_wait.js +183 -0
- package/stall_wait.js.map +1 -0
- package/stall_wait.ts +249 -0
- package/stall_wait_worker.ts +11 -0
- package/start.js +349 -0
- package/start.js.map +1 -0
- package/start.ts +343 -0
- package/starvation.js +147 -0
- package/starvation.js.map +1 -0
- package/starvation.ts +224 -0
- package/store.js +118 -0
- package/store.js.map +1 -0
- package/store.ts +193 -0
- package/subcommands.js +62 -0
- package/subcommands.js.map +1 -0
- package/subcommands.ts +77 -0
- package/terminal.js +93 -0
- package/terminal.js.map +1 -0
- package/terminal.ts +128 -0
- package/text.js +20 -0
- package/text.js.map +1 -0
- package/text.ts +37 -0
- package/tool.js +76 -0
- package/tool.js.map +1 -0
- package/tool.ts +157 -0
- package/trace_control.js +231 -0
- package/trace_control.js.map +1 -0
- package/trace_control.ts +233 -0
- package/traces.js +138 -0
- package/traces.js.map +1 -0
- package/traces.ts +160 -0
- package/tracker.js +22 -0
- package/tracker.js.map +1 -0
- package/tracker.ts +27 -0
- package/tty.js +82 -0
- package/tty.js.map +1 -0
- package/tty.ts +142 -0
- package/unit_failure.js +178 -0
- package/unit_failure.js.map +1 -0
- package/unit_failure.ts +191 -0
- package/upkeep_thread.js +32 -0
- package/upkeep_thread.js.map +1 -0
- package/upkeep_thread.ts +35 -0
- package/upkeep_worker.ts +27 -0
- package/vault.js +186 -0
- package/vault.js.map +1 -0
- package/vault.ts +220 -0
- package/vocab-ids.js +63 -0
- package/vocab-ids.js.map +1 -0
- package/vocab-ids.ts +62 -0
- package/vocab.json +35 -0
- package/warm.js +138 -0
- package/warm.js.map +1 -0
- package/warm.ts +171 -0
- package/watch_revision.js +25 -0
- package/watch_revision.js.map +1 -0
- package/watch_revision.ts +30 -0
- package/words.js +29 -0
- package/words.js.map +1 -0
- package/words.ts +41 -0
- package/workspaces.js +40 -0
- package/workspaces.js.map +1 -0
- package/workspaces.ts +58 -0
- package/yak-unit-failure.conf +6 -0
- package/yak-unit-handoff.conf +2 -0
- package/yak.js +123 -0
- package/yak.js.map +1 -0
- package/yak.ts +136 -0
package/reader.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// A file-backed reader, with vocabulary and ID resolution but no writers,
|
|
2
|
+
// processes, graph hooks or services. A preflight that only needs stored rows
|
|
3
|
+
// never composes the imperative host around a graph.
|
|
4
|
+
import { reader as graph } from "@yaks/graph/read";
|
|
5
|
+
import { ids } from "@yaks/id/graph";
|
|
6
|
+
import { reader as storage } from "@yaks/sqlite/reader";
|
|
7
|
+
import { open } from "@yaks/sqlite/read-db";
|
|
8
|
+
import { requirements } from "@yaks/sqlite/meta";
|
|
9
|
+
import { loadVocab } from "@yaks/vocab/runtime";
|
|
10
|
+
import { dbOf, subpath } from "./config.js";
|
|
11
|
+
import { understood } from "@yaks/host/keywords";
|
|
12
|
+
import { meet } from "@yaks/host/config";
|
|
13
|
+
/** Read the stored components declared by `plugins` in an installed graph.
|
|
14
|
+
* The caller chooses its vocabulary; no plugin's executable graph facet runs.
|
|
15
|
+
* The reader cannot apply a write and the file itself is opened read-only. */ export let reader = async (config, plugins)=>{
|
|
16
|
+
let facets = await Promise.all(plugins.map((p)=>subpath(p, 'vocab')));
|
|
17
|
+
let vocab = loadVocab(facets.flatMap((f)=>f?.docs ?? []), understood(facets.flatMap((f)=>f?.keywords ?? [])));
|
|
18
|
+
let sql = open(dbOf(config));
|
|
19
|
+
try {
|
|
20
|
+
// Opened under `config`, so refused where `config` lacks a plugin the
|
|
21
|
+
// store requires, the way the host it reads beside would be.
|
|
22
|
+
meet(config, requirements(sql));
|
|
23
|
+
let derived = Object.assign({}, ...facets.map((f)=>f?.derived?.(vocab)));
|
|
24
|
+
let store = storage(sql, vocab, {
|
|
25
|
+
derived,
|
|
26
|
+
backed: Object.assign({}, ...facets.map((f)=>f?.backed?.(vocab, derived)))
|
|
27
|
+
});
|
|
28
|
+
let g = graph({
|
|
29
|
+
storage: store,
|
|
30
|
+
vocab,
|
|
31
|
+
plugins: [
|
|
32
|
+
ids(vocab)
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
graph: {
|
|
37
|
+
read: g.read,
|
|
38
|
+
get: g.get,
|
|
39
|
+
address: g.address
|
|
40
|
+
},
|
|
41
|
+
close: ()=>sql.close()
|
|
42
|
+
};
|
|
43
|
+
} catch (e) {
|
|
44
|
+
sql.close();
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=reader.js.map
|
package/reader.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.js","sources":["./reader.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,8EAA8E;AAC9E,qDAAqD;AAErD,SAAS,UAAU,KAAK,gCAAqC;AAC7D,SAAS,GAAG,8BAAmC;AAC/C,SAAS,UAAU,OAAO,mCAAwC;AAClE,SAAS,IAAI,oCAAyC;AACtD,SAAS,YAAY,iCAAsC;AAC3D,SAAS,SAAS,mCAAwC;AAC1D,SAAsB,IAAI,EAAE,OAAO,sBAAqB;AACxD,SAAS,UAAU,mCAAwC;AAC3D,SAAS,IAAI,iCAAsC;AAQnD;;4EAE4E,GAC5E,OAAO,IAAI,SAAS,OAClB,QACA;EAEA,IAAI,SAAS,MAAM,QAAQ,GAAG,CAC5B,QAAQ,GAAG,CAAC,CAAC,IAAM,QAAoB,GAAG;EAE5C,IAAI,QAAQ,UACV,OAAO,OAAO,CAAC,CAAC,IAAM,GAAG,QAAQ,EAAE,GACnC,WAAW,OAAO,OAAO,CAAC,CAAC,IAAM,GAAG,YAAY,EAAE;EAEpD,IAAI,MAAM,KAAK,KAAK;EACpB,IAAI;IACF,sEAAsE;IACtE,6DAA6D;IAC7D,KAAK,QAAQ,aAAa;IAC1B,IAAI,UAAU,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,IAAM,GAAG,UAAU;IAClE,IAAI,QAAQ,QAAQ,KAAK,OAAO;MAC9B;MACA,QAAQ,OAAO,MAAM,CACnB,CAAC,MACE,OAAO,GAAG,CAAC,CAAC,IAAM,GAAG,SAAS,OAAO;IAE5C;IACA,IAAI,IAAI,MAAM;MAAE,SAAS;MAAO;MAAO,SAAS;QAAC,IAAI;OAAO;IAAC;IAC7D,OAAO;MACL,OAAO;QAAE,MAAM,EAAE,IAAI;QAAE,KAAK,EAAE,GAAG;QAAE,SAAS,EAAE,OAAO;MAAC;MACtD,OAAO,IAAM,IAAI,KAAK;IACxB;EACF,EAAE,OAAO,GAAG;IACV,IAAI,KAAK;IACT,MAAM;EACR;AACF,EAAC"}
|
package/reader.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// A file-backed reader, with vocabulary and ID resolution but no writers,
|
|
2
|
+
// processes, graph hooks or services. A preflight that only needs stored rows
|
|
3
|
+
// never composes the imperative host around a graph.
|
|
4
|
+
import type { Graph } from 'jsr:@yaks/graph@0.2.36'
|
|
5
|
+
import { reader as graph } from '@yaks/graph/read'
|
|
6
|
+
import { ids } from '@yaks/id/graph'
|
|
7
|
+
import { reader as storage } from '@yaks/sqlite/reader'
|
|
8
|
+
import { open } from '@yaks/sqlite/read-db'
|
|
9
|
+
import { requirements } from '@yaks/sqlite/meta'
|
|
10
|
+
import { loadVocab } from '@yaks/vocab/runtime'
|
|
11
|
+
import { type Config, dbOf, subpath } from './config.js'
|
|
12
|
+
import { understood } from '@yaks/host/keywords'
|
|
13
|
+
import { meet } from '@yaks/host/config'
|
|
14
|
+
import type { VocabFacet } from 'jsr:@yaks/host@0.2.36'
|
|
15
|
+
|
|
16
|
+
export type Reader = {
|
|
17
|
+
graph: Pick<Graph, 'read' | 'get' | 'address'>
|
|
18
|
+
close: () => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Read the stored components declared by `plugins` in an installed graph.
|
|
22
|
+
* The caller chooses its vocabulary; no plugin's executable graph facet runs.
|
|
23
|
+
* The reader cannot apply a write and the file itself is opened read-only. */
|
|
24
|
+
export let reader = async (
|
|
25
|
+
config: Config,
|
|
26
|
+
plugins: string[],
|
|
27
|
+
): Promise<Reader> => {
|
|
28
|
+
let facets = await Promise.all(
|
|
29
|
+
plugins.map((p) => subpath<VocabFacet>(p, 'vocab')),
|
|
30
|
+
)
|
|
31
|
+
let vocab = loadVocab(
|
|
32
|
+
facets.flatMap((f) => f?.docs ?? []),
|
|
33
|
+
understood(facets.flatMap((f) => f?.keywords ?? [])),
|
|
34
|
+
)
|
|
35
|
+
let sql = open(dbOf(config))
|
|
36
|
+
try {
|
|
37
|
+
// Opened under `config`, so refused where `config` lacks a plugin the
|
|
38
|
+
// store requires, the way the host it reads beside would be.
|
|
39
|
+
meet(config, requirements(sql))
|
|
40
|
+
let derived = Object.assign({}, ...facets.map((f) => f?.derived?.(vocab)))
|
|
41
|
+
let store = storage(sql, vocab, {
|
|
42
|
+
derived,
|
|
43
|
+
backed: Object.assign(
|
|
44
|
+
{},
|
|
45
|
+
...facets.map((f) => f?.backed?.(vocab, derived)),
|
|
46
|
+
),
|
|
47
|
+
})
|
|
48
|
+
let g = graph({ storage: store, vocab, plugins: [ids(vocab)] })
|
|
49
|
+
return {
|
|
50
|
+
graph: { read: g.read, get: g.get, address: g.address },
|
|
51
|
+
close: () => sql.close(),
|
|
52
|
+
}
|
|
53
|
+
} catch (e) {
|
|
54
|
+
sql.close()
|
|
55
|
+
throw e
|
|
56
|
+
}
|
|
57
|
+
}
|
package/release.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as disk from "@yaks/file/io";
|
|
2
|
+
// A release publishes the @yaks package set at one version. ./release.json
|
|
3
|
+
// names its packages (bin/release.ts). Plugins the CLI loads by name use
|
|
4
|
+
// that same version (./config.ts `located`).
|
|
5
|
+
//
|
|
6
|
+
// Deno 2.9 waits a day before it resolves any version newer than that (its
|
|
7
|
+
// minimum dependency age). On the day a release publishes, a resolver under
|
|
8
|
+
// that default finds none of the release's other packages, so it takes the
|
|
9
|
+
// one before or refuses outright. Whatever resolves a release — the installer
|
|
10
|
+
// (./install.ts), @yaks/web's bundler — does so under `released`, which lifts
|
|
11
|
+
// the wait for the release's own packages alone: every other dependency keeps
|
|
12
|
+
// Deno's window. jsr.io's scope listing cannot say which those are: its CDN
|
|
13
|
+
// serves the listing up to a day old, so a package publishing for the first
|
|
14
|
+
// time is missing from it on exactly the day it has to be exempt.
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
import at from './release.json' with {
|
|
17
|
+
type: 'json'
|
|
18
|
+
};
|
|
19
|
+
import subpaths from './exports.json' with {
|
|
20
|
+
type: 'json'
|
|
21
|
+
};
|
|
22
|
+
/** A Deno config keeping the default minimum dependency age for everything but
|
|
23
|
+
* the JSR packages named.
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { assertEquals } from '@std/assert'
|
|
27
|
+
* assertEquals(exempt(['@yaks/cli', '@yaks/doc']), {
|
|
28
|
+
* minimumDependencyAge: {
|
|
29
|
+
* age: 'P1D',
|
|
30
|
+
* exclude: ['jsr:@yaks/cli', 'jsr:@yaks/doc'],
|
|
31
|
+
* },
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/ export let exempt = (names)=>({
|
|
35
|
+
minimumDependencyAge: {
|
|
36
|
+
age: 'P1D',
|
|
37
|
+
exclude: names.map((name)=>`jsr:${name}`)
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
/** The version of each @yaks package this release is made of. */ export let pinned = at;
|
|
41
|
+
/** The subpaths each package of this release exports (`.`, `./vocab`, …),
|
|
42
|
+
* which bin/publish.ts writes into ./exports.json as it publishes: a module
|
|
43
|
+
* from JSR resolves any subpath of a package and finds one missing only by
|
|
44
|
+
* loading it. A checkout's is empty, since its import map knows. */ export let shipped = subpaths;
|
|
45
|
+
/** The unstable features a release runs with: this repository's deno.json's.
|
|
46
|
+
* `lazy-dynamic-imports` is the one a person waits on: without it Deno loads
|
|
47
|
+
* every module a literal `import()` reaches before the program starts
|
|
48
|
+
* (./yak.ts `local`), and a `yak serve` from JSR listens 0.4 s later.
|
|
49
|
+
* `raw-imports` reads the files a package ships from Deno's module cache
|
|
50
|
+
* instead of jsr.io (@yaks/api/asset). */ export let UNSTABLE = [
|
|
51
|
+
'net',
|
|
52
|
+
'lazy-dynamic-imports',
|
|
53
|
+
'raw-imports',
|
|
54
|
+
'no-legacy-abort'
|
|
55
|
+
];
|
|
56
|
+
/** The config a resolver of this release runs under. */ export let released = {
|
|
57
|
+
...exempt(Object.keys(pinned)),
|
|
58
|
+
unstable: UNSTABLE
|
|
59
|
+
};
|
|
60
|
+
/** The Deno config a `deno` process this CLI starts runs under: a checkout's
|
|
61
|
+
* own deno.json, or, for a CLI served from JSR, `released` written into the
|
|
62
|
+
* directory `dir` makes, so the child resolves the same release its parent
|
|
63
|
+
* did.
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { assertEquals } from '@std/assert'
|
|
67
|
+
* import * as disk from '@yaks/file/io'
|
|
68
|
+
* let dir = () => disk.makeTempDir()
|
|
69
|
+
* assertEquals(await launching(dir, 'file:///repo/packages/cli/release.ts'), '/repo/deno.json')
|
|
70
|
+
* let config = await launching(dir, 'https://jsr.io/@yaks/cli/1.2.3/release.ts')
|
|
71
|
+
* assertEquals(JSON.parse(await disk.readTextFile(config)), released)
|
|
72
|
+
* ```
|
|
73
|
+
*/ export let launching = async (dir, source = import.meta.url)=>{
|
|
74
|
+
let here = new URL(source);
|
|
75
|
+
if (here.protocol == 'file:') {
|
|
76
|
+
return fileURLToPath(new URL('../../deno.json', here));
|
|
77
|
+
}
|
|
78
|
+
let config = `${await dir()}/deno.json`;
|
|
79
|
+
await disk.writeTextFile(config, JSON.stringify(released));
|
|
80
|
+
return config;
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=release.js.map
|
package/release.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release.js","sources":["./release.ts"],"names":[],"mappings":"AAAA,YAAY,+BAAoC;AAChD,2EAA2E;AAC3E,yEAAyE;AACzE,6CAA6C;AAC7C,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,4EAA4E;AAC5E,kEAAkE;AAElE,SAAS,aAAa,QAAQ,WAAU;AACxC,OAAO,QAAQ,sBAAsB;EAAE,MAAM;AAAO,EAAC;AACrD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAO3D;;;;;;;;;;;;CAYC,GACD,OAAO,IAAI,SAAS,CAAC,QAA+B,CAAC;IACnD,sBAAsB;MACpB,KAAK;MACL,SAAS,MAAM,GAAG,CAAC,CAAC,OAAS,CAAC,IAAI,EAAE,MAAM;IAC5C;EACF,CAAC,EAAC;AAEF,+DAA+D,GAC/D,OAAO,IAAI,SAA2C,GAAE;AAExD;;;kEAGkE,GAClE,OAAO,IAAI,UAAuD,SAAQ;AAE1E;;;;;wCAKwC,GACxC,OAAO,IAAI,WAAW;EACpB;EACA;EACA;EACA;CACD,CAAA;AAED,sDAAsD,GACtD,OAAO,IAAI,WAA+C;EACxD,GAAG,OAAO,OAAO,IAAI,CAAC,QAAQ;EAC9B,UAAU;AACZ,EAAC;AAED;;;;;;;;;;;;;CAaC,GACD,OAAO,IAAI,YAAY,OACrB,KACA,SAAiB,YAAY,GAAG;EAEhC,IAAI,OAAO,IAAI,IAAI;EACnB,IAAI,KAAK,QAAQ,IAAI,SAAS;IAC5B,OAAO,cAAc,IAAI,IAAI,mBAAmB;EAClD;EACA,IAAI,SAAS,GAAG,MAAM,MAAM,UAAU,CAAC;EACvC,MAAM,KAAK,aAAa,CAAC,QAAQ,KAAK,SAAS,CAAC;EAChD,OAAO;AACT,EAAC"}
|
package/release.json
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@yaks/alias": "0.2.36",
|
|
3
|
+
"@yaks/anthropic": "0.2.36",
|
|
4
|
+
"@yaks/api": "0.2.36",
|
|
5
|
+
"@yaks/archetype": "0.2.36",
|
|
6
|
+
"@yaks/benchmark": "0.2.36",
|
|
7
|
+
"@yaks/blob": "0.2.36",
|
|
8
|
+
"@yaks/browse": "0.2.36",
|
|
9
|
+
"@yaks/browser": "0.2.36",
|
|
10
|
+
"@yaks/builders": "0.2.36",
|
|
11
|
+
"@yaks/canvas": "0.2.36",
|
|
12
|
+
"@yaks/claude": "0.2.36",
|
|
13
|
+
"@yaks/cli": "0.2.36",
|
|
14
|
+
"@yaks/client": "0.2.36",
|
|
15
|
+
"@yaks/cloudflare-mail": "0.2.36",
|
|
16
|
+
"@yaks/code": "0.2.36",
|
|
17
|
+
"@yaks/code-mode": "0.2.36",
|
|
18
|
+
"@yaks/connections": "0.2.36",
|
|
19
|
+
"@yaks/context": "0.2.36",
|
|
20
|
+
"@yaks/copy": "0.2.36",
|
|
21
|
+
"@yaks/d1": "0.2.36",
|
|
22
|
+
"@yaks/data-editor": "0.2.36",
|
|
23
|
+
"@yaks/design": "0.2.36",
|
|
24
|
+
"@yaks/diagram": "0.2.36",
|
|
25
|
+
"@yaks/doc": "0.2.36",
|
|
26
|
+
"@yaks/dom": "0.2.36",
|
|
27
|
+
"@yaks/draft": "0.2.36",
|
|
28
|
+
"@yaks/dreaming": "0.2.36",
|
|
29
|
+
"@yaks/durable-object": "0.2.36",
|
|
30
|
+
"@yaks/edge": "0.2.36",
|
|
31
|
+
"@yaks/effects": "0.2.36",
|
|
32
|
+
"@yaks/egress": "0.2.36",
|
|
33
|
+
"@yaks/embedding": "0.2.36",
|
|
34
|
+
"@yaks/esbuild": "0.2.36",
|
|
35
|
+
"@yaks/extension": "0.2.36",
|
|
36
|
+
"@yaks/feedback": "0.2.36",
|
|
37
|
+
"@yaks/file": "0.2.36",
|
|
38
|
+
"@yaks/filter": "0.2.36",
|
|
39
|
+
"@yaks/fp": "0.2.36",
|
|
40
|
+
"@yaks/fts": "0.2.36",
|
|
41
|
+
"@yaks/game": "0.2.36",
|
|
42
|
+
"@yaks/git": "0.2.36",
|
|
43
|
+
"@yaks/goal": "0.2.36",
|
|
44
|
+
"@yaks/graph": "0.2.36",
|
|
45
|
+
"@yaks/harness": "0.2.36",
|
|
46
|
+
"@yaks/heal": "0.2.36",
|
|
47
|
+
"@yaks/hook": "0.2.36",
|
|
48
|
+
"@yaks/host": "0.2.36",
|
|
49
|
+
"@yaks/html": "0.2.36",
|
|
50
|
+
"@yaks/id": "0.2.36",
|
|
51
|
+
"@yaks/inbox": "0.2.36",
|
|
52
|
+
"@yaks/inspect": "0.2.36",
|
|
53
|
+
"@yaks/journal": "0.2.36",
|
|
54
|
+
"@yaks/kernel": "0.2.36",
|
|
55
|
+
"@yaks/key": "0.2.36",
|
|
56
|
+
"@yaks/lens": "0.2.36",
|
|
57
|
+
"@yaks/logic": "0.2.36",
|
|
58
|
+
"@yaks/machine": "0.2.36",
|
|
59
|
+
"@yaks/mail": "0.2.36",
|
|
60
|
+
"@yaks/markdown": "0.2.36",
|
|
61
|
+
"@yaks/match": "0.2.36",
|
|
62
|
+
"@yaks/mcp": "0.2.36",
|
|
63
|
+
"@yaks/mcp-client": "0.2.36",
|
|
64
|
+
"@yaks/member": "0.2.36",
|
|
65
|
+
"@yaks/memory": "0.2.36",
|
|
66
|
+
"@yaks/mirror": "0.2.36",
|
|
67
|
+
"@yaks/model": "0.2.36",
|
|
68
|
+
"@yaks/model2vec": "0.2.36",
|
|
69
|
+
"@yaks/names": "0.2.36",
|
|
70
|
+
"@yaks/native": "0.2.36",
|
|
71
|
+
"@yaks/notify": "0.2.36",
|
|
72
|
+
"@yaks/oauth": "0.2.36",
|
|
73
|
+
"@yaks/openai": "0.2.36",
|
|
74
|
+
"@yaks/openrouter": "0.2.36",
|
|
75
|
+
"@yaks/page": "0.2.36",
|
|
76
|
+
"@yaks/persona": "0.2.36",
|
|
77
|
+
"@yaks/phone": "0.2.36",
|
|
78
|
+
"@yaks/pinnacle": "0.2.36",
|
|
79
|
+
"@yaks/platform": "0.2.36",
|
|
80
|
+
"@yaks/preact": "0.2.36",
|
|
81
|
+
"@yaks/process": "0.2.36",
|
|
82
|
+
"@yaks/project": "0.2.36",
|
|
83
|
+
"@yaks/provenance": "0.2.36",
|
|
84
|
+
"@yaks/push": "0.2.36",
|
|
85
|
+
"@yaks/query": "0.2.36",
|
|
86
|
+
"@yaks/ram": "0.2.36",
|
|
87
|
+
"@yaks/reach": "0.2.36",
|
|
88
|
+
"@yaks/react": "0.2.36",
|
|
89
|
+
"@yaks/render": "0.2.36",
|
|
90
|
+
"@yaks/resend": "0.2.36",
|
|
91
|
+
"@yaks/rtc": "0.2.36",
|
|
92
|
+
"@yaks/sandbox": "0.2.36",
|
|
93
|
+
"@yaks/secrets": "0.2.36",
|
|
94
|
+
"@yaks/session": "0.2.36",
|
|
95
|
+
"@yaks/spawn": "0.2.36",
|
|
96
|
+
"@yaks/speech": "0.2.36",
|
|
97
|
+
"@yaks/spend": "0.2.36",
|
|
98
|
+
"@yaks/sql": "0.2.36",
|
|
99
|
+
"@yaks/sqlite": "0.2.36",
|
|
100
|
+
"@yaks/stage": "0.2.36",
|
|
101
|
+
"@yaks/stripe": "0.2.36",
|
|
102
|
+
"@yaks/sync": "0.2.36",
|
|
103
|
+
"@yaks/task": "0.2.36",
|
|
104
|
+
"@yaks/telnyx": "0.2.36",
|
|
105
|
+
"@yaks/testing": "0.2.36",
|
|
106
|
+
"@yaks/text": "0.2.36",
|
|
107
|
+
"@yaks/threads": "0.2.36",
|
|
108
|
+
"@yaks/timing": "0.2.36",
|
|
109
|
+
"@yaks/tmux": "0.2.36",
|
|
110
|
+
"@yaks/tools": "0.2.36",
|
|
111
|
+
"@yaks/topic": "0.2.36",
|
|
112
|
+
"@yaks/trace": "0.2.36",
|
|
113
|
+
"@yaks/tracker": "0.2.36",
|
|
114
|
+
"@yaks/tui": "0.2.36",
|
|
115
|
+
"@yaks/tunnel": "0.2.36",
|
|
116
|
+
"@yaks/ui": "0.2.36",
|
|
117
|
+
"@yaks/ux": "0.2.36",
|
|
118
|
+
"@yaks/visualize": "0.2.36",
|
|
119
|
+
"@yaks/vocab": "0.2.36",
|
|
120
|
+
"@yaks/voipms": "0.2.36",
|
|
121
|
+
"@yaks/voxel": "0.2.36",
|
|
122
|
+
"@yaks/wake": "0.2.36",
|
|
123
|
+
"@yaks/web": "0.2.36",
|
|
124
|
+
"@yaks/workerd": "0.2.36",
|
|
125
|
+
"@yaks/workers-ai": "0.2.36",
|
|
126
|
+
"@yaks/yaml": "0.2.36"
|
|
127
|
+
}
|
package/release.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as disk from '@yaks/file/io'
|
|
2
|
+
// A release publishes the @yaks package set at one version. ./release.json
|
|
3
|
+
// names its packages (bin/release.ts). Plugins the CLI loads by name use
|
|
4
|
+
// that same version (./config.ts `located`).
|
|
5
|
+
//
|
|
6
|
+
// Deno 2.9 waits a day before it resolves any version newer than that (its
|
|
7
|
+
// minimum dependency age). On the day a release publishes, a resolver under
|
|
8
|
+
// that default finds none of the release's other packages, so it takes the
|
|
9
|
+
// one before or refuses outright. Whatever resolves a release — the installer
|
|
10
|
+
// (./install.ts), @yaks/web's bundler — does so under `released`, which lifts
|
|
11
|
+
// the wait for the release's own packages alone: every other dependency keeps
|
|
12
|
+
// Deno's window. jsr.io's scope listing cannot say which those are: its CDN
|
|
13
|
+
// serves the listing up to a day old, so a package publishing for the first
|
|
14
|
+
// time is missing from it on exactly the day it has to be exempt.
|
|
15
|
+
|
|
16
|
+
import { fileURLToPath } from 'node:url'
|
|
17
|
+
import at from './release.json' with { type: 'json' }
|
|
18
|
+
import subpaths from './exports.json' with { type: 'json' }
|
|
19
|
+
|
|
20
|
+
/** The part of a Deno config that says which versions it will resolve. */
|
|
21
|
+
export type Resolving = {
|
|
22
|
+
minimumDependencyAge: { age: string; exclude: string[] }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** A Deno config keeping the default minimum dependency age for everything but
|
|
26
|
+
* the JSR packages named.
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { assertEquals } from '@std/assert'
|
|
30
|
+
* assertEquals(exempt(['@yaks/cli', '@yaks/doc']), {
|
|
31
|
+
* minimumDependencyAge: {
|
|
32
|
+
* age: 'P1D',
|
|
33
|
+
* exclude: ['jsr:@yaks/cli', 'jsr:@yaks/doc'],
|
|
34
|
+
* },
|
|
35
|
+
* })
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export let exempt = (names: string[]): Resolving => ({
|
|
39
|
+
minimumDependencyAge: {
|
|
40
|
+
age: 'P1D',
|
|
41
|
+
exclude: names.map((name) => `jsr:${name}`),
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
/** The version of each @yaks package this release is made of. */
|
|
46
|
+
export let pinned: Readonly<Record<string, string>> = at
|
|
47
|
+
|
|
48
|
+
/** The subpaths each package of this release exports (`.`, `./vocab`, …),
|
|
49
|
+
* which bin/publish.ts writes into ./exports.json as it publishes: a module
|
|
50
|
+
* from JSR resolves any subpath of a package and finds one missing only by
|
|
51
|
+
* loading it. A checkout's is empty, since its import map knows. */
|
|
52
|
+
export let shipped: Readonly<Record<string, readonly string[]>> = subpaths
|
|
53
|
+
|
|
54
|
+
/** The unstable features a release runs with: this repository's deno.json's.
|
|
55
|
+
* `lazy-dynamic-imports` is the one a person waits on: without it Deno loads
|
|
56
|
+
* every module a literal `import()` reaches before the program starts
|
|
57
|
+
* (./yak.ts `local`), and a `yak serve` from JSR listens 0.4 s later.
|
|
58
|
+
* `raw-imports` reads the files a package ships from Deno's module cache
|
|
59
|
+
* instead of jsr.io (@yaks/api/asset). */
|
|
60
|
+
export let UNSTABLE = [
|
|
61
|
+
'net',
|
|
62
|
+
'lazy-dynamic-imports',
|
|
63
|
+
'raw-imports',
|
|
64
|
+
'no-legacy-abort',
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
/** The config a resolver of this release runs under. */
|
|
68
|
+
export let released: Resolving & { unstable: string[] } = {
|
|
69
|
+
...exempt(Object.keys(pinned)),
|
|
70
|
+
unstable: UNSTABLE,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The Deno config a `deno` process this CLI starts runs under: a checkout's
|
|
74
|
+
* own deno.json, or, for a CLI served from JSR, `released` written into the
|
|
75
|
+
* directory `dir` makes, so the child resolves the same release its parent
|
|
76
|
+
* did.
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { assertEquals } from '@std/assert'
|
|
80
|
+
* import * as disk from '@yaks/file/io'
|
|
81
|
+
* let dir = () => disk.makeTempDir()
|
|
82
|
+
* assertEquals(await launching(dir, 'file:///repo/packages/cli/release.ts'), '/repo/deno.json')
|
|
83
|
+
* let config = await launching(dir, 'https://jsr.io/@yaks/cli/1.2.3/release.ts')
|
|
84
|
+
* assertEquals(JSON.parse(await disk.readTextFile(config)), released)
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export let launching = async (
|
|
88
|
+
dir: () => Promise<string>,
|
|
89
|
+
source: string = import.meta.url,
|
|
90
|
+
): Promise<string> => {
|
|
91
|
+
let here = new URL(source)
|
|
92
|
+
if (here.protocol == 'file:') {
|
|
93
|
+
return fileURLToPath(new URL('../../deno.json', here))
|
|
94
|
+
}
|
|
95
|
+
let config = `${await dir()}/deno.json`
|
|
96
|
+
await disk.writeTextFile(config, JSON.stringify(released))
|
|
97
|
+
return config
|
|
98
|
+
}
|
package/remote-page.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Published JSR plugins have remote module graphs until the npm release
|
|
2
|
+
// migration completes (D-135458 step 6). Keep that compatibility resolver at
|
|
3
|
+
// this boundary; local workspace bundles use esbuild's package resolution.
|
|
4
|
+
// ./page.ts imports this only when it makes a body, so a host that makes none
|
|
5
|
+
// never downloads esbuild or the loader.
|
|
6
|
+
import { context, type Plugin, type PluginBuild } from 'npm:esbuild@0.28.1'
|
|
7
|
+
import { denoPlugins, urlToEsbuildResolution } from 'jsr:@luca/esbuild-deno-loader@0.11.1'
|
|
8
|
+
import * as disk from 'jsr:@yaks/file@0.2.36/io'
|
|
9
|
+
import { released } from './release.ts'
|
|
10
|
+
import { type Bundling, compiled, pageExternals, type Written } from './page.ts'
|
|
11
|
+
|
|
12
|
+
export let bundle = async (
|
|
13
|
+
entry: URL | Written,
|
|
14
|
+
signal?: AbortSignal,
|
|
15
|
+
opts: Bundling = {},
|
|
16
|
+
): Promise<string> => {
|
|
17
|
+
let at = entry instanceof URL ? entry : entry.at
|
|
18
|
+
let dir = await disk.makeTempDir({ prefix: 'yaks-page-' })
|
|
19
|
+
let from = entry instanceof URL ? entry : new URL('./.yak-page.ts', at)
|
|
20
|
+
let virtual = urlToEsbuildResolution(from)
|
|
21
|
+
try {
|
|
22
|
+
await disk.writeTextFile(`${dir}/deno.json`, JSON.stringify(released))
|
|
23
|
+
let configPath = `${dir}/deno.json`
|
|
24
|
+
if (signal?.aborted) throw new Error('browser bundle was stopped')
|
|
25
|
+
let build = await context({
|
|
26
|
+
absWorkingDir: dir,
|
|
27
|
+
entryPoints: [from.href],
|
|
28
|
+
bundle: true,
|
|
29
|
+
alias: opts.alias,
|
|
30
|
+
format: opts.format ?? 'esm',
|
|
31
|
+
platform: 'browser',
|
|
32
|
+
target: 'esnext',
|
|
33
|
+
// esbuild reads no deno.json: said here, or JSX compiles to `React`.
|
|
34
|
+
jsx: 'automatic',
|
|
35
|
+
jsxImportSource: 'react',
|
|
36
|
+
minify: true,
|
|
37
|
+
write: false,
|
|
38
|
+
logLevel: 'silent',
|
|
39
|
+
plugins: [
|
|
40
|
+
pageExternals(opts.external),
|
|
41
|
+
...entry instanceof URL ? [] : [{
|
|
42
|
+
name: 'written',
|
|
43
|
+
setup(build: PluginBuild) {
|
|
44
|
+
build.onResolve(
|
|
45
|
+
{ filter: /.*/ },
|
|
46
|
+
(args) =>
|
|
47
|
+
args.kind == 'entry-point' && args.path == from.href
|
|
48
|
+
? virtual
|
|
49
|
+
: undefined,
|
|
50
|
+
)
|
|
51
|
+
build.onLoad(
|
|
52
|
+
{ filter: /.*/, namespace: virtual.namespace },
|
|
53
|
+
(args) =>
|
|
54
|
+
args.path == virtual.path
|
|
55
|
+
? { contents: entry.code, loader: 'ts' }
|
|
56
|
+
: undefined,
|
|
57
|
+
)
|
|
58
|
+
},
|
|
59
|
+
}],
|
|
60
|
+
// The loader carries esbuild 0.20 types; its plugin API is unchanged.
|
|
61
|
+
...denoPlugins(
|
|
62
|
+
{ configPath },
|
|
63
|
+
) as Plugin[],
|
|
64
|
+
],
|
|
65
|
+
})
|
|
66
|
+
return await compiled(build, signal)
|
|
67
|
+
} finally {
|
|
68
|
+
await disk.remove(dir, { recursive: true })
|
|
69
|
+
}
|
|
70
|
+
}
|
package/remote.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as system from "@yaks/process/system";
|
|
2
|
+
import { importing } from "@yaks/fp/imports";
|
|
3
|
+
import { CallError } from "@yaks/tools/errors";
|
|
4
|
+
import { tokenFor } from "./store.js";
|
|
5
|
+
import { doorUrl, rpc } from "./rpc.js";
|
|
6
|
+
import { saidBy } from "./roster.js";
|
|
7
|
+
import { located, person } from "./config.js";
|
|
8
|
+
import { adminForward, boxAccount, forwarded } from "./account-forward.js";
|
|
9
|
+
/** Authenticated JSON delivery shared by HTTP commands and graph tools. */ export let readJson = async (url, options = {})=>{
|
|
10
|
+
let origin = new URL(url);
|
|
11
|
+
if (![
|
|
12
|
+
'http:',
|
|
13
|
+
'https:'
|
|
14
|
+
].includes(origin.protocol) || origin.username || origin.password) {
|
|
15
|
+
throw new CallError('arguments', 'Choose an HTTP(S) origin without credentials');
|
|
16
|
+
}
|
|
17
|
+
let key = options.host && new URL(doorUrl(options.host)).origin == origin.origin ? options.host : origin.host;
|
|
18
|
+
let token = options.credential ? await options.credential(key, options.as, !!options.via) : await tokenFor(key, options.state, {
|
|
19
|
+
config: options.config,
|
|
20
|
+
as: options.as,
|
|
21
|
+
env: options.env,
|
|
22
|
+
agent: !!options.via
|
|
23
|
+
});
|
|
24
|
+
let headers = new Headers({
|
|
25
|
+
accept: 'application/json'
|
|
26
|
+
});
|
|
27
|
+
if (token) headers.set('authorization', `Bearer ${token}`);
|
|
28
|
+
if (options.via) headers.set('x-via', options.via);
|
|
29
|
+
let destination = forwarded(origin.href, token, false, {
|
|
30
|
+
headers,
|
|
31
|
+
redirect: 'error',
|
|
32
|
+
cache: 'no-store'
|
|
33
|
+
});
|
|
34
|
+
let response = await (options.fetch ?? globalThis.fetch)(destination.url, destination.init);
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
await response.body?.cancel();
|
|
37
|
+
throw new Error(`HTTP ${response.status} ${response.statusText}`.trim());
|
|
38
|
+
}
|
|
39
|
+
return await response.json();
|
|
40
|
+
};
|
|
41
|
+
export let remote = async (name, args, options = {})=>{
|
|
42
|
+
let origin = new URL(options.url ?? 'https://yaks.app');
|
|
43
|
+
if (![
|
|
44
|
+
'http:',
|
|
45
|
+
'https:'
|
|
46
|
+
].includes(origin.protocol) || origin.username || origin.password) {
|
|
47
|
+
throw new CallError('arguments', 'Choose an HTTP(S) origin without credentials');
|
|
48
|
+
}
|
|
49
|
+
let door = new URL(doorUrl(origin.origin));
|
|
50
|
+
if (options.mixedAuth) door.searchParams.set('auth', 'mixed');
|
|
51
|
+
let ask = rpc({
|
|
52
|
+
url: door.href,
|
|
53
|
+
token: ()=>options.credential ? options.credential(origin.origin, options.as, !!options.via) : tokenFor(origin.origin, options.state, {
|
|
54
|
+
as: options.as,
|
|
55
|
+
config: options.config,
|
|
56
|
+
agent: !!options.via
|
|
57
|
+
}),
|
|
58
|
+
via: options.via
|
|
59
|
+
});
|
|
60
|
+
let reply = await ask('tools/call', {
|
|
61
|
+
name,
|
|
62
|
+
arguments: args
|
|
63
|
+
});
|
|
64
|
+
if (reply.isError) throw new CallError('remote', saidBy(reply).text);
|
|
65
|
+
let result = reply.structuredContent?.result;
|
|
66
|
+
if (!Array.isArray(result)) throw new Error(`${name} returned no bundles`);
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
/** Bind delivery to this host's owner and vault, including nondefault configs. */ export let delivery = (host)=>{
|
|
70
|
+
let credential = async (name, as, agent)=>{
|
|
71
|
+
let explicit = system.env.get('YAKS_TOKEN');
|
|
72
|
+
if (explicit) return explicit;
|
|
73
|
+
let url = new URL(doorUrl(name));
|
|
74
|
+
if (url.origin == 'https://yaks.app') {
|
|
75
|
+
as = boxAccount(host.config, as, agent);
|
|
76
|
+
let forwarded = adminForward(host.config, as);
|
|
77
|
+
if (forwarded) return forwarded;
|
|
78
|
+
}
|
|
79
|
+
let owner = await person(host);
|
|
80
|
+
if (!owner || !host.graph.vocab.comp('connection')) return null;
|
|
81
|
+
let { accountCredential } = await importing(import.meta.resolve(located('@yaks/connections')));
|
|
82
|
+
let integration = url.hostname == 'yaks.app' ? 'yaks.app' : url.href;
|
|
83
|
+
return (await accountCredential(host, owner, integration, as))?.bearer ?? null;
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
remote: (name, args, options)=>remote(name, args, {
|
|
87
|
+
...options,
|
|
88
|
+
credential
|
|
89
|
+
}),
|
|
90
|
+
readJson: (url, options)=>readJson(url, {
|
|
91
|
+
...options,
|
|
92
|
+
credential
|
|
93
|
+
})
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=remote.js.map
|
package/remote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