pinecall 0.4.0 → 0.6.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/README.md +14 -6
- package/dist/cli/agent-files.d.ts +6 -0
- package/dist/cli/agent-files.d.ts.map +1 -0
- package/dist/cli/agent-files.js +40 -0
- package/dist/cli/agent-files.js.map +1 -0
- package/dist/cli/agent-lines.d.ts +23 -0
- package/dist/cli/agent-lines.d.ts.map +1 -0
- package/dist/cli/agent-lines.js +109 -0
- package/dist/cli/agent-lines.js.map +1 -0
- package/dist/cli/agent-processes.d.ts +13 -0
- package/dist/cli/agent-processes.d.ts.map +1 -0
- package/dist/cli/agent-processes.js +34 -0
- package/dist/cli/agent-processes.js.map +1 -0
- package/dist/cli/agent-versions.d.ts +12 -0
- package/dist/cli/agent-versions.d.ts.map +1 -0
- package/dist/cli/agent-versions.js +70 -0
- package/dist/cli/agent-versions.js.map +1 -0
- package/dist/cli/agent.d.ts +77 -0
- package/dist/cli/agent.d.ts.map +1 -0
- package/dist/cli/agent.js +186 -0
- package/dist/cli/agent.js.map +1 -0
- package/dist/cli/chat.d.ts +2 -2
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +12 -24
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/client-for.d.ts +6 -0
- package/dist/cli/client-for.d.ts.map +1 -0
- package/dist/cli/client-for.js +7 -0
- package/dist/cli/client-for.js.map +1 -0
- package/dist/cli/connected.d.ts +4 -4
- package/dist/cli/connected.d.ts.map +1 -1
- package/dist/cli/connected.js +2 -2
- package/dist/cli/connected.js.map +1 -1
- package/dist/cli/dotenv.d.ts +24 -0
- package/dist/cli/dotenv.d.ts.map +1 -0
- package/dist/cli/dotenv.js +69 -0
- package/dist/cli/dotenv.js.map +1 -0
- package/dist/cli/env.d.ts +21 -37
- package/dist/cli/env.d.ts.map +1 -1
- package/dist/cli/env.js +35 -68
- package/dist/cli/env.js.map +1 -1
- package/dist/cli/eval.d.ts +2 -1
- package/dist/cli/eval.d.ts.map +1 -1
- package/dist/cli/eval.js +5 -4
- package/dist/cli/eval.js.map +1 -1
- package/dist/cli/groups.d.ts.map +1 -1
- package/dist/cli/groups.js +0 -1
- package/dist/cli/groups.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +25 -30
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/lexicon.d.ts +14 -0
- package/dist/cli/lexicon.d.ts.map +1 -0
- package/dist/cli/lexicon.js +123 -0
- package/dist/cli/lexicon.js.map +1 -0
- package/dist/cli/line.js +6 -6
- package/dist/cli/line.js.map +1 -1
- package/dist/cli/linking.d.ts +13 -0
- package/dist/cli/linking.d.ts.map +1 -0
- package/dist/cli/linking.js +103 -0
- package/dist/cli/linking.js.map +1 -0
- package/dist/cli/load.js +1 -1
- package/dist/cli/load.js.map +1 -1
- package/dist/cli/login.d.ts +5 -11
- package/dist/cli/login.d.ts.map +1 -1
- package/dist/cli/login.js +31 -140
- package/dist/cli/login.js.map +1 -1
- package/dist/cli/memory-policy.d.ts +9 -0
- package/dist/cli/memory-policy.d.ts.map +1 -0
- package/dist/cli/memory-policy.js +79 -0
- package/dist/cli/memory-policy.js.map +1 -0
- package/dist/cli/memory.d.ts.map +1 -1
- package/dist/cli/memory.js +9 -1
- package/dist/cli/memory.js.map +1 -1
- package/dist/cli/pipeline.d.ts +2 -0
- package/dist/cli/pipeline.d.ts.map +1 -1
- package/dist/cli/pipeline.js +18 -76
- package/dist/cli/pipeline.js.map +1 -1
- package/dist/cli/serve/server.d.ts +1 -1
- package/dist/cli/serve/server.d.ts.map +1 -1
- package/dist/cli/serve/server.js +3 -2
- package/dist/cli/serve/server.js.map +1 -1
- package/dist/cli/serve/sidecar.js +1 -1
- package/dist/cli/serve/sidecar.js.map +1 -1
- package/dist/cli/serve.d.ts +1 -1
- package/dist/cli/serve.d.ts.map +1 -1
- package/dist/cli/serve.js +5 -5
- package/dist/cli/serve.js.map +1 -1
- package/dist/cli/signed-in.d.ts +36 -0
- package/dist/cli/signed-in.d.ts.map +1 -0
- package/dist/cli/signed-in.js +60 -0
- package/dist/cli/signed-in.js.map +1 -0
- package/dist/cli/simulate.d.ts.map +1 -1
- package/dist/cli/simulate.js +7 -6
- package/dist/cli/simulate.js.map +1 -1
- package/dist/cli/{run-console.d.ts → start-console.d.ts} +2 -2
- package/dist/cli/start-console.d.ts.map +1 -0
- package/dist/cli/{run-console.js → start-console.js} +3 -3
- package/dist/cli/start-console.js.map +1 -0
- package/dist/cli/{run-screens.d.ts → start-screens.d.ts} +2 -2
- package/dist/cli/start-screens.d.ts.map +1 -0
- package/dist/cli/{run-screens.js → start-screens.js} +24 -5
- package/dist/cli/start-screens.js.map +1 -0
- package/dist/cli/{run.d.ts → start.d.ts} +3 -3
- package/dist/cli/start.d.ts.map +1 -0
- package/dist/cli/{run.js → start.js} +31 -35
- package/dist/cli/start.js.map +1 -0
- package/dist/cli/supervise.d.ts +1 -1
- package/dist/cli/supervise.d.ts.map +1 -1
- package/dist/cli/supervise.js +1 -1
- package/dist/cli/supervise.js.map +1 -1
- package/dist/cli/testing/gateway.d.ts +3 -0
- package/dist/cli/testing/gateway.d.ts.map +1 -1
- package/dist/cli/testing/gateway.js +2 -4
- package/dist/cli/testing/gateway.js.map +1 -1
- package/dist/cli/tuned.d.ts +8 -0
- package/dist/cli/tuned.d.ts.map +1 -0
- package/dist/cli/tuned.js +66 -0
- package/dist/cli/tuned.js.map +1 -0
- package/dist/cli/ui/chatting.d.ts +1 -1
- package/dist/cli/ui/chatting.d.ts.map +1 -1
- package/dist/cli/ui/chatting.js +11 -10
- package/dist/cli/ui/chatting.js.map +1 -1
- package/dist/cli/ui/console/assets/index-DmN15Axn.css +1 -0
- package/dist/cli/ui/console/assets/index-aGyMCQUH.js +106 -0
- package/dist/cli/ui/console/index.html +2 -2
- package/dist/cli/ui/doors.d.ts +2 -2
- package/dist/cli/ui/doors.d.ts.map +1 -1
- package/dist/cli/ui/doors.js +2 -2
- package/dist/cli/ui/doors.js.map +1 -1
- package/dist/cli/ui/drifting.d.ts +1 -1
- package/dist/cli/ui/drifting.js +1 -1
- package/dist/cli/ui/knowing.d.ts +1 -1
- package/dist/cli/ui/knowing.js +3 -3
- package/dist/cli/ui/knowing.js.map +1 -1
- package/dist/cli/ui/promoting.d.ts +1 -1
- package/dist/cli/ui/promoting.js +1 -1
- package/dist/cli/ui/remembering.d.ts +1 -1
- package/dist/cli/ui/remembering.js +3 -3
- package/dist/cli/ui/remembering.js.map +1 -1
- package/dist/cli/ui/reproducing.d.ts +1 -1
- package/dist/cli/ui/reproducing.js +1 -1
- package/dist/cli/ui/simulating.d.ts +1 -1
- package/dist/cli/ui/simulating.js +4 -4
- package/dist/cli/ui/simulating.js.map +1 -1
- package/dist/cli/ui/testing.d.ts +1 -1
- package/dist/cli/ui/testing.js +3 -3
- package/dist/cli/ui/testing.js.map +1 -1
- package/dist/cli/whoami.d.ts +6 -2
- package/dist/cli/whoami.d.ts.map +1 -1
- package/dist/cli/whoami.js +6 -5
- package/dist/cli/whoami.js.map +1 -1
- package/dist/cli/world.d.ts +14 -24
- package/dist/cli/world.d.ts.map +1 -1
- package/dist/cli/world.js +21 -36
- package/dist/cli/world.js.map +1 -1
- package/dist/client/agent.d.ts +2 -1
- package/dist/client/agent.d.ts.map +1 -1
- package/dist/client/agent.js +3 -2
- package/dist/client/agent.js.map +1 -1
- package/dist/client/client.d.ts +17 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +44 -2
- package/dist/client/client.js.map +1 -1
- package/dist/client/connection.d.ts +3 -0
- package/dist/client/connection.d.ts.map +1 -1
- package/dist/client/connection.js +2 -1
- package/dist/client/connection.js.map +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/observe.d.ts +3 -0
- package/dist/client/observe.d.ts.map +1 -1
- package/dist/client/observe.js +2 -1
- package/dist/client/observe.js.map +1 -1
- package/dist/client/signed.d.ts +15 -0
- package/dist/client/signed.d.ts.map +1 -0
- package/dist/client/signed.js +19 -0
- package/dist/client/signed.js.map +1 -0
- package/dist/client/testing/gateway.d.ts +5 -0
- package/dist/client/testing/gateway.d.ts.map +1 -1
- package/dist/client/testing/gateway.js +10 -0
- package/dist/client/testing/gateway.js.map +1 -1
- package/dist/views/render.d.ts +1 -1
- package/dist/views/render.js +1 -1
- package/package.json +2 -2
- package/dist/cli/config.d.ts +0 -16
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -125
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/credentials.d.ts +0 -41
- package/dist/cli/credentials.d.ts.map +0 -1
- package/dist/cli/credentials.js +0 -98
- package/dist/cli/credentials.js.map +0 -1
- package/dist/cli/gateway.d.ts +0 -12
- package/dist/cli/gateway.d.ts.map +0 -1
- package/dist/cli/gateway.js +0 -67
- package/dist/cli/gateway.js.map +0 -1
- package/dist/cli/keys.d.ts +0 -28
- package/dist/cli/keys.d.ts.map +0 -1
- package/dist/cli/keys.js +0 -137
- package/dist/cli/keys.js.map +0 -1
- package/dist/cli/profiles.d.ts +0 -122
- package/dist/cli/profiles.d.ts.map +0 -1
- package/dist/cli/profiles.js +0 -312
- package/dist/cli/profiles.js.map +0 -1
- package/dist/cli/run-console.d.ts.map +0 -1
- package/dist/cli/run-console.js.map +0 -1
- package/dist/cli/run-screens.d.ts.map +0 -1
- package/dist/cli/run-screens.js.map +0 -1
- package/dist/cli/run.d.ts.map +0 -1
- package/dist/cli/run.js.map +0 -1
- package/dist/cli/ui/console/assets/index-DhcpHPdk.js +0 -102
- package/dist/cli/ui/console/assets/index-iylvEP0_.css +0 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/** `pinecall agent`: what the org set over the class — yours, the team's, production's — setting it, and the processes that hold it. */
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
import { FIELDS, linesOf, readSettings, settingsPath, WIRE } from "./agent-lines.js";
|
|
4
|
+
import { filesRun } from "./agent-files.js";
|
|
5
|
+
import { listed, stopped } from "./agent-processes.js";
|
|
6
|
+
import { versionsRun } from "./agent-versions.js";
|
|
7
|
+
import { theDoor } from "./env.js";
|
|
8
|
+
import { agentOfThisDirectory, notASlug } from "./load.js";
|
|
9
|
+
import { asked } from "./testing/gateway.js";
|
|
10
|
+
import { refusal } from "./whoami.js";
|
|
11
|
+
const USAGE = [
|
|
12
|
+
"usage: pinecall agent [--agent <slug>] [--json]",
|
|
13
|
+
" pinecall agent list · stop <app>",
|
|
14
|
+
" pinecall agent set [--voice x] [--tts x] [--tts-model x] [--stt x] [--llm x] [--greeting '…' | --reply '…']",
|
|
15
|
+
" [--hangup '…'] [--endpointing-ms n] [--min-interruption-words n]",
|
|
16
|
+
" [--remember '…' …] [--forget '…' …] [--team] [--note '…']",
|
|
17
|
+
" pinecall agent clear [voice|tts|tts-model|stt|llm|greeting|hangup|turn|memory|knowledge …] [--team]",
|
|
18
|
+
" pinecall agent history [--team] · diff [--against team|production] · rollback <version> [--team]",
|
|
19
|
+
" pinecall agent pull [--team] · push <file> [--team]",
|
|
20
|
+
].join("\n");
|
|
21
|
+
export const group = {
|
|
22
|
+
purpose: "what the org set over the class — yours, the team's, production's — setting it, and the processes that hold it",
|
|
23
|
+
usage: `${USAGE}
|
|
24
|
+
|
|
25
|
+
With nothing after it: the agent's settings as your key sees them, three corners side by side —
|
|
26
|
+
your own sandbox corner, the team's, and production's — a row per field, and which version each
|
|
27
|
+
corner is at. A corner that set nothing reads as what it falls back to.
|
|
28
|
+
|
|
29
|
+
set writes a NEW version in your own corner: what you set is yours, and a colleague's next call
|
|
30
|
+
does not hear it. --team writes the org's own corner instead, which every corner falls back to.
|
|
31
|
+
--prod writes production's, if your org lets you act there. The whole set travels with the version it was read at, so two people
|
|
32
|
+
saving at once never write over each other: the second is told where the corner is now. A model
|
|
33
|
+
knob reads three ways — \`--llm anthropic/claude-haiku-4-5\`, \`--llm cartesia\` (a vendor, its own
|
|
34
|
+
model), \`--llm claude-haiku-4-5\` (a model, the vendor in use). --greeting sets the words said as
|
|
35
|
+
the call opens; --reply what the model reads before it finds its own. --remember and --forget
|
|
36
|
+
replace those lists whole. A field nobody names is left as it stands.
|
|
37
|
+
|
|
38
|
+
clear takes fields out of the corner's own row, so what the class declared — or the runtime's
|
|
39
|
+
default — stands for them again; with no name, every field. There is no blank value.
|
|
40
|
+
|
|
41
|
+
history, diff and rollback are the versions: every one kept, who set it and why; this corner
|
|
42
|
+
against the team's or production's; one version back as the next one — with --prod, production's.
|
|
43
|
+
pull prints the corner's config as JSON; push sends a file as the next version, --team to the
|
|
44
|
+
team's corner.
|
|
45
|
+
|
|
46
|
+
list prints every process holding this org's agents in the world asked — one line an app: its id,
|
|
47
|
+
the agents it holds, whose corner, the machine and the address it connected from, the SDK, and
|
|
48
|
+
since when. stop <app> closes that app's socket; a pinecall that hears it exits instead of
|
|
49
|
+
dialling back, so its agents are free — though a supervisor (systemd, pm2) starts it again.`,
|
|
50
|
+
run,
|
|
51
|
+
};
|
|
52
|
+
/** Every flag the sub-verbs take, declared once: parseArgs is strict, and one table is one seam. */
|
|
53
|
+
export const OPTIONS = {
|
|
54
|
+
agent: { type: "string" },
|
|
55
|
+
json: { type: "boolean", default: false },
|
|
56
|
+
team: { type: "boolean", default: false },
|
|
57
|
+
note: { type: "string" },
|
|
58
|
+
voice: { type: "string" },
|
|
59
|
+
tts: { type: "string" },
|
|
60
|
+
"tts-model": { type: "string" },
|
|
61
|
+
stt: { type: "string" },
|
|
62
|
+
llm: { type: "string" },
|
|
63
|
+
greeting: { type: "string" },
|
|
64
|
+
reply: { type: "string" },
|
|
65
|
+
hangup: { type: "string" },
|
|
66
|
+
"endpointing-ms": { type: "string" },
|
|
67
|
+
"min-interruption-words": { type: "string" },
|
|
68
|
+
remember: { type: "string", multiple: true },
|
|
69
|
+
forget: { type: "string", multiple: true },
|
|
70
|
+
against: { type: "string" },
|
|
71
|
+
};
|
|
72
|
+
export async function run(argv, how = {}) {
|
|
73
|
+
const out = how.out ?? process.stdout;
|
|
74
|
+
const err = how.err ?? process.stderr;
|
|
75
|
+
const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, options: OPTIONS });
|
|
76
|
+
const door = theDoor(how.env ?? process.env, err);
|
|
77
|
+
if (door === undefined)
|
|
78
|
+
return 2;
|
|
79
|
+
const [verb, ...rest] = positionals;
|
|
80
|
+
try {
|
|
81
|
+
if (verb === "list")
|
|
82
|
+
return await listed(door, out);
|
|
83
|
+
if (verb === "stop")
|
|
84
|
+
return await stopped(door, rest[0], out, err);
|
|
85
|
+
const aFile = notASlug(values.agent);
|
|
86
|
+
if (aFile !== undefined) {
|
|
87
|
+
err.write(`${aFile}\n`);
|
|
88
|
+
return 2;
|
|
89
|
+
}
|
|
90
|
+
const agent = values.agent ?? (await agentOfThisDirectory());
|
|
91
|
+
if (agent === null || agent === undefined) {
|
|
92
|
+
err.write(`${USAGE}\n name the agent, or run this beside an agent file\n`);
|
|
93
|
+
return 2;
|
|
94
|
+
}
|
|
95
|
+
if (verb === undefined)
|
|
96
|
+
return said(agent, await readSettings(door, agent), values.json === true, out);
|
|
97
|
+
if (verb === "set")
|
|
98
|
+
return said(agent, await set(door, agent, values), values.json === true, out);
|
|
99
|
+
if (verb === "clear")
|
|
100
|
+
return said(agent, await clear(door, agent, rest, values.team === true), values.json === true, out);
|
|
101
|
+
if (verb === "history" || verb === "diff" || verb === "rollback") {
|
|
102
|
+
return await versionsRun(door, agent, verb, rest, values, out, err);
|
|
103
|
+
}
|
|
104
|
+
if (verb === "pull" || verb === "push")
|
|
105
|
+
return await filesRun(door, agent, verb, rest, values, out, err);
|
|
106
|
+
}
|
|
107
|
+
catch (refused) {
|
|
108
|
+
// The gateway's own sentence: it knows this build's vendors, the corner's version, and which
|
|
109
|
+
// half of the settings a key opens — and every refusal names the one it was.
|
|
110
|
+
err.write(`${refusal(refused)}\n`);
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
err.write(`${USAGE}\n`);
|
|
114
|
+
return 2;
|
|
115
|
+
}
|
|
116
|
+
// ── the verbs ───────────────────────────────────────────────────────────────────
|
|
117
|
+
// The door takes the WHOLE set with the version it was read at, so what this command line did
|
|
118
|
+
// not name is read back off the corner's own row and sent again: `set --llm x` must not quietly
|
|
119
|
+
// take the voice out of the row. The corner written is yours, or the team's with --team.
|
|
120
|
+
async function set(door, agent, values) {
|
|
121
|
+
const standing = await readSettings(door, agent);
|
|
122
|
+
const row = values.team === true ? standing.team : standing.yours;
|
|
123
|
+
const config = { ...(row?.config ?? {}), ...typed(values, row?.config ?? {}) };
|
|
124
|
+
return await asked(door, settingsPath(agent), {
|
|
125
|
+
method: "PUT",
|
|
126
|
+
body: { config, if_version: row?.version ?? null, note: values.note ?? null, team: values.team === true },
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async function clear(door, agent, named, team) {
|
|
130
|
+
const unknown = named.filter((name) => !FIELDS.includes(name));
|
|
131
|
+
if (unknown.length > 0)
|
|
132
|
+
throw new Error(`no field called ${unknown.join(", ")}: ${FIELDS.join(" · ")}`);
|
|
133
|
+
const standing = await readSettings(door, agent);
|
|
134
|
+
const row = team ? standing.team : standing.yours;
|
|
135
|
+
const config = named.length === 0 ? {} : { ...(row?.config ?? {}) };
|
|
136
|
+
for (const name of named)
|
|
137
|
+
delete config[WIRE[name]];
|
|
138
|
+
return await asked(door, settingsPath(agent), {
|
|
139
|
+
method: "PUT",
|
|
140
|
+
body: { config, if_version: row?.version ?? null, note: named.length === 0 ? "cleared" : `cleared ${named.join(", ")}`, team },
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** What this command line set, under the wire's names, over what the corner's row already says. */
|
|
144
|
+
export function typed(values, standing) {
|
|
145
|
+
const wanted = {};
|
|
146
|
+
for (const field of ["voice", "tts", "tts-model", "stt", "llm"]) {
|
|
147
|
+
const value = values[field];
|
|
148
|
+
if (typeof value === "string")
|
|
149
|
+
wanted[WIRE[field]] = value;
|
|
150
|
+
}
|
|
151
|
+
if (values.greeting !== undefined)
|
|
152
|
+
wanted.greeting = { say: values.greeting };
|
|
153
|
+
else if (values.reply !== undefined)
|
|
154
|
+
wanted.greeting = { reply: values.reply };
|
|
155
|
+
if (values.hangup !== undefined)
|
|
156
|
+
wanted.hangup = { when: values.hangup };
|
|
157
|
+
const endpointing = numberOf(values["endpointing-ms"]);
|
|
158
|
+
const words = numberOf(values["min-interruption-words"]);
|
|
159
|
+
if (endpointing !== undefined || words !== undefined) {
|
|
160
|
+
wanted.turn = { ...(standing.turn ?? {}) };
|
|
161
|
+
if (endpointing !== undefined)
|
|
162
|
+
wanted.turn.endpointing_ms = endpointing;
|
|
163
|
+
if (words !== undefined)
|
|
164
|
+
wanted.turn.min_interruption_words = words;
|
|
165
|
+
}
|
|
166
|
+
if (values.remember !== undefined || values.forget !== undefined) {
|
|
167
|
+
wanted.memory = {
|
|
168
|
+
remember: values.remember ?? standing.memory?.remember ?? [],
|
|
169
|
+
forget: values.forget ?? standing.memory?.forget ?? [],
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return wanted;
|
|
173
|
+
}
|
|
174
|
+
function numberOf(said) {
|
|
175
|
+
if (said === undefined)
|
|
176
|
+
return undefined;
|
|
177
|
+
const number = Number(said);
|
|
178
|
+
if (!Number.isInteger(number) || number < 0)
|
|
179
|
+
throw new Error(`${said} is not a whole number`);
|
|
180
|
+
return number;
|
|
181
|
+
}
|
|
182
|
+
function said(agent, answer, asJson, out) {
|
|
183
|
+
out.write(asJson ? `${JSON.stringify(answer)}\n` : `${linesOf(agent, answer).join("\n")}\n`);
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/cli/agent.ts"],"names":[],"mappings":"AAAA,wIAAwI;AAExI,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,OA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,11 @@ export declare const group: Group;
|
|
|
6
6
|
* the caller. Typing goes out as `{ text }`; everything that comes back is the call's own log,
|
|
7
7
|
* printed as it lands. The tools run in this process, so a breakpoint in a @tool is reachable.
|
|
8
8
|
*
|
|
9
|
-
* This is `rails console`: it works with no `pinecall
|
|
9
|
+
* This is `rails console`: it works with no `pinecall start` up and it works with three of them,
|
|
10
10
|
* because the caller socket names THIS process's app id and the gateway serves the call from it.
|
|
11
11
|
*
|
|
12
12
|
* Named an agent instead, it mounts nothing and is only the caller's side: a written call at
|
|
13
|
-
* whatever is holding that slug — your own `
|
|
13
|
+
* whatever is holding that slug — your own `start` in the other terminal, or a colleague's. The
|
|
14
14
|
* positional is a SLUG and `--file` is the file, because `--agent` meaning one thing in three
|
|
15
15
|
* verbs and the other in six was a flag nobody could read.
|
|
16
16
|
*/
|
package/dist/cli/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/cli/chat.ts"],"names":[],"mappings":"AAAA,8GAA8G;
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/cli/chat.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAY9G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAQzC,eAAO,MAAM,KAAK,EAAE,KAoBnB,CAAC;AASF;;;;;;;;;;;;GAYG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAwDzD;AAED,iGAAiG;AACjG,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAc3F;AAoED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMnD"}
|
package/dist/cli/chat.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/** `pinecall chat [agent]`: this directory's agent in this process, or a written call at one already held. */
|
|
2
2
|
import { createInterface } from "node:readline";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
|
-
import {
|
|
4
|
+
import { signed } from "../client/signed.js";
|
|
5
5
|
import WebSocket from "ws";
|
|
6
6
|
import { mount } from "../runtime/connect.js";
|
|
7
|
+
import { pinecallFor } from "./client-for.js";
|
|
7
8
|
import { theDoor } from "./env.js";
|
|
8
9
|
import { load, mountOptions, notASlug } from "./load.js";
|
|
9
10
|
import { AGENT_FLAG, oneHome } from "./home.js";
|
|
10
|
-
import { cannotTell, ENV_FLAG, notThisWorld, standing } from "./world.js";
|
|
11
11
|
import { BROKE, CALLER, lineFor } from "./view.js";
|
|
12
12
|
import { firstState } from "./prompt.js";
|
|
13
13
|
const PROMPT = `${CALLER} `;
|
|
14
14
|
export const group = {
|
|
15
15
|
purpose: "the app in this terminal's own process, and a prompt against it",
|
|
16
|
-
usage: `usage: pinecall chat [agent] [--agent <name>] [--file agent.tsx] [--
|
|
16
|
+
usage: `usage: pinecall chat [agent] [--agent <name>] [--file agent.tsx] [--prod] [--as <contact>]
|
|
17
17
|
[--state file [--case n]] [--events]
|
|
18
18
|
|
|
19
19
|
With nothing after it: the agent of this directory, mounted in THIS process, and a written
|
|
20
20
|
caller against it. The tools run here, so a breakpoint in a @tool is reachable.
|
|
21
21
|
|
|
22
22
|
With an agent's slug: a written call at the agent somebody is already holding — your own
|
|
23
|
-
\`pinecall
|
|
23
|
+
\`pinecall start\` in another terminal, or a colleague's. Nothing is mounted here, so --state,
|
|
24
24
|
which opens a call in a class this process built, is refused.
|
|
25
25
|
|
|
26
26
|
--agent <name> which agent of a project of several, by its file's name or its slug
|
|
27
27
|
--file <path> which class to mount, by its path
|
|
28
|
-
--
|
|
28
|
+
--prod production's agent, if your org lets you act there; the sandbox otherwise
|
|
29
29
|
--as <contact> who is calling: the id memory files this call under (a phone number, a customer id)
|
|
30
30
|
--state file the state the call opens in — the same goldens file \`pinecall prompt\` reads
|
|
31
31
|
--case n which case of that file, when it holds several
|
|
@@ -42,11 +42,11 @@ const NOT_YOURS_TO_OPEN = "--state opens a call in a class this process mounted,
|
|
|
42
42
|
* the caller. Typing goes out as `{ text }`; everything that comes back is the call's own log,
|
|
43
43
|
* printed as it lands. The tools run in this process, so a breakpoint in a @tool is reachable.
|
|
44
44
|
*
|
|
45
|
-
* This is `rails console`: it works with no `pinecall
|
|
45
|
+
* This is `rails console`: it works with no `pinecall start` up and it works with three of them,
|
|
46
46
|
* because the caller socket names THIS process's app id and the gateway serves the call from it.
|
|
47
47
|
*
|
|
48
48
|
* Named an agent instead, it mounts nothing and is only the caller's side: a written call at
|
|
49
|
-
* whatever is holding that slug — your own `
|
|
49
|
+
* whatever is holding that slug — your own `start` in the other terminal, or a colleague's. The
|
|
50
50
|
* positional is a SLUG and `--file` is the file, because `--agent` meaning one thing in three
|
|
51
51
|
* verbs and the other in six was a flag nobody could read.
|
|
52
52
|
*/
|
|
@@ -61,7 +61,6 @@ export async function run(argv) {
|
|
|
61
61
|
file: { type: "string" },
|
|
62
62
|
...AGENT_FLAG,
|
|
63
63
|
events: { type: "boolean", default: false },
|
|
64
|
-
...ENV_FLAG,
|
|
65
64
|
},
|
|
66
65
|
});
|
|
67
66
|
const reach = positionals[0];
|
|
@@ -77,23 +76,12 @@ export async function run(argv) {
|
|
|
77
76
|
const door = theDoor();
|
|
78
77
|
if (door === undefined)
|
|
79
78
|
return 2;
|
|
80
|
-
try {
|
|
81
|
-
const elsewhere = notThisWorld("chat", await standing(door), values.env);
|
|
82
|
-
if (elsewhere !== undefined) {
|
|
83
|
-
process.stderr.write(`${elsewhere}\n`);
|
|
84
|
-
return 2;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
catch (failed) {
|
|
88
|
-
process.stderr.write(`${cannotTell("chat", failed)}\n`);
|
|
89
|
-
return 2;
|
|
90
|
-
}
|
|
91
79
|
const url = door.url;
|
|
92
80
|
if (reach !== undefined) {
|
|
93
|
-
return await talk(chatUrl(url, reach, undefined, values.as), door
|
|
81
|
+
return await talk(chatUrl(url, reach, undefined, values.as), door, values.events === true);
|
|
94
82
|
}
|
|
95
83
|
const loaded = await load((await oneHome("chat", values.file, values.agent)).file);
|
|
96
|
-
const pc =
|
|
84
|
+
const pc = pinecallFor(door);
|
|
97
85
|
// takesUnclaimed: false is the other half of the `?app=` below. Holding the agent is what makes
|
|
98
86
|
// this a console; taking a call nobody named would make it a server, and a real phone call would
|
|
99
87
|
// ring in this terminal. See the runtime's docs/decisions/dispatch.md: the registry is its.
|
|
@@ -114,7 +102,7 @@ export async function run(argv) {
|
|
|
114
102
|
// The id exists only after the register the connect awaited, which is why it is read here
|
|
115
103
|
// and not where the agent was mounted.
|
|
116
104
|
const address = chatUrl(url, mounted.slug, mounted.agent.app, values.as);
|
|
117
|
-
return await talk(address, door
|
|
105
|
+
return await talk(address, door, values.events === true);
|
|
118
106
|
}
|
|
119
107
|
finally {
|
|
120
108
|
pc.close();
|
|
@@ -141,8 +129,8 @@ export function chatUrl(base, agent, app, contact) {
|
|
|
141
129
|
// Every line typed is one turn; every frame received is one entry, printed as it lands. The key
|
|
142
130
|
// travels as the upgrade's Authorization header, never in the URL, which is the only thing the
|
|
143
131
|
// chat door accepts and the reason this socket is `ws` and not the runtime's global WebSocket.
|
|
144
|
-
function talk(url,
|
|
145
|
-
const socket = new WebSocket(url, { headers:
|
|
132
|
+
function talk(url, door, events) {
|
|
133
|
+
const socket = new WebSocket(url, { headers: signed(door.apiKey, door.world) });
|
|
146
134
|
const lines = createInterface({ input: process.stdin, output: process.stdout, prompt: PROMPT });
|
|
147
135
|
// An entry can land after the keyboard is gone — a piped stdin ends the moment it is read, and
|
|
148
136
|
// the agent's greeting arrives after that — and readline throws on a prompt it has closed.
|
package/dist/cli/chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRo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AAI,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The SDK client a verb holds: the door's gateway, its key, and the world the command named. */
|
|
2
|
+
import { Pinecall } from "../client/client.js";
|
|
3
|
+
import type { Door } from "./testing/gateway.js";
|
|
4
|
+
/** A client for this door. A verb that opens no socket never imports this, and so never `ws`. */
|
|
5
|
+
export declare function pinecallFor(door: Door): Pinecall;
|
|
6
|
+
//# sourceMappingURL=client-for.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-for.d.ts","sourceRoot":"","sources":["../../src/cli/client-for.ts"],"names":[],"mappings":"AAAA,iGAAiG;AAEjG,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEjD,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAEhD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The SDK client a verb holds: the door's gateway, its key, and the world the command named. */
|
|
2
|
+
import { Pinecall } from "../client/client.js";
|
|
3
|
+
/** A client for this door. A verb that opens no socket never imports this, and so never `ws`. */
|
|
4
|
+
export function pinecallFor(door) {
|
|
5
|
+
return new Pinecall({ url: door.url, apiKey: door.apiKey, ...(door.world === undefined ? {} : { env: door.world }) });
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=client-for.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-for.js","sourceRoot":"","sources":["../../src/cli/client-for.ts"],"names":[],"mappings":"AAAA,iGAAiG;AAEjG,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,iGAAiG;AACjG,MAAM,UAAU,WAAW,CAAC,IAAU;IACpC,OAAO,IAAI,QAAQ,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AACxH,CAAC"}
|
package/dist/cli/connected.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** The one line `pinecall
|
|
1
|
+
/** The one line `pinecall start` prints when the socket is up: who registered, where, and as whom. */
|
|
2
2
|
import type { RouteInput } from "../client/index.js";
|
|
3
3
|
export interface Connected {
|
|
4
4
|
slug: string;
|
|
@@ -8,12 +8,12 @@ export interface Connected {
|
|
|
8
8
|
/** Whose org took it, and which of the two worlds. Absent when the gateway would not say. */
|
|
9
9
|
org?: string;
|
|
10
10
|
env?: string;
|
|
11
|
-
/**
|
|
12
|
-
* above, and because it used to be
|
|
11
|
+
/** Where the key that opened the door was read — the environment, or the project's .env. Said
|
|
12
|
+
* because it decides the two above, and because it used to be whatever the shell exported. */
|
|
13
13
|
source?: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* The one line `pinecall
|
|
16
|
+
* The one line `pinecall start` prints when the socket is up.
|
|
17
17
|
*
|
|
18
18
|
* It used to say the gateway and nothing else, and that cost an afternoon: a key exported in the
|
|
19
19
|
* shell wins over the one `pinecall login` just kept, so an agent could register into another org
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connected.d.ts","sourceRoot":"","sources":["../../src/cli/connected.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"connected.d.ts","sourceRoot":"","sources":["../../src/cli/connected.ts"],"names":[],"mappings":"AAAA,sGAAsG;AAEtG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,6FAA6F;IAC7F,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;kGAC8F;IAC9F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAStD;AAED,uGAAuG;AACvG,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,CAIlE"}
|
package/dist/cli/connected.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/** The one line `pinecall
|
|
1
|
+
/** The one line `pinecall start` prints when the socket is up: who registered, where, and as whom. */
|
|
2
2
|
/**
|
|
3
|
-
* The one line `pinecall
|
|
3
|
+
* The one line `pinecall start` prints when the socket is up.
|
|
4
4
|
*
|
|
5
5
|
* It used to say the gateway and nothing else, and that cost an afternoon: a key exported in the
|
|
6
6
|
* shell wins over the one `pinecall login` just kept, so an agent could register into another org
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connected.js","sourceRoot":"","sources":["../../src/cli/connected.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"connected.js","sourceRoot":"","sources":["../../src/cli/connected.ts"],"names":[],"mappings":"AAAA,sGAAsG;AAiBtG;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,KAAgB;IAC5C,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,CAAC,IAAI,CAAC,gBAAgB,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IACvC,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACtE,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAClC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,OAAO,CAAC,MAAgC;IACtD,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAClC,KAAK,CAAC,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE,CACzG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A project's `.env`: the nearest one up from where a verb runs, read as dotenv lines, and written by `link`. */
|
|
2
|
+
export declare const DOTENV = ".env";
|
|
3
|
+
/** The nearest `.env` from this directory up to the filesystem's root, or undefined when none. */
|
|
4
|
+
export declare function nearestDotenv(from: string): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* The file's variables. The dotenv every tool agrees on and nothing more: `NAME=value`, a value in
|
|
7
|
+
* matching quotes is taken inside them, `export ` in front is allowed, and a line starting with `#`
|
|
8
|
+
* or holding no `=` says nothing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readDotenv(file: string): Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* These variables written into the file: a line that names one is replaced where it stands, one
|
|
13
|
+
* that is not there yet goes at the end, and every other line — a comment, the app's own
|
|
14
|
+
* variables — is left exactly as it was. A file that does not exist is made readable by its owner
|
|
15
|
+
* alone, because what it holds is a key.
|
|
16
|
+
*/
|
|
17
|
+
export declare function writeDotenv(file: string, values: Record<string, string>): void;
|
|
18
|
+
/**
|
|
19
|
+
* Whether git keeps this file out of a commit: a key committed is a key published. Git answers it
|
|
20
|
+
* — every `.gitignore` up to the repository's root, and the global one — so the answer is the one
|
|
21
|
+
* a commit would act on. Outside a repository, or with no git at all, nothing can commit it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function ignoredByGit(file: string): boolean;
|
|
24
|
+
//# sourceMappingURL=dotenv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dotenv.d.ts","sourceRoot":"","sources":["../../src/cli/dotenv.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAMlH,eAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAS/D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAY9E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIlD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** A project's `.env`: the nearest one up from where a verb runs, read as dotenv lines, and written by `link`. */
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
export const DOTENV = ".env";
|
|
6
|
+
/** The nearest `.env` from this directory up to the filesystem's root, or undefined when none. */
|
|
7
|
+
export function nearestDotenv(from) {
|
|
8
|
+
for (let at = from;; at = dirname(at)) {
|
|
9
|
+
const file = join(at, DOTENV);
|
|
10
|
+
if (existsSync(file))
|
|
11
|
+
return file;
|
|
12
|
+
if (dirname(at) === at)
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The file's variables. The dotenv every tool agrees on and nothing more: `NAME=value`, a value in
|
|
18
|
+
* matching quotes is taken inside them, `export ` in front is allowed, and a line starting with `#`
|
|
19
|
+
* or holding no `=` says nothing.
|
|
20
|
+
*/
|
|
21
|
+
export function readDotenv(file) {
|
|
22
|
+
const found = {};
|
|
23
|
+
for (const raw of readFileSync(file, "utf8").split(/\r?\n/)) {
|
|
24
|
+
const line = raw.trim().replace(/^export\s+/, "");
|
|
25
|
+
const equals = line.indexOf("=");
|
|
26
|
+
if (line.startsWith("#") || equals <= 0)
|
|
27
|
+
continue;
|
|
28
|
+
found[line.slice(0, equals).trim()] = unquoted(line.slice(equals + 1).trim());
|
|
29
|
+
}
|
|
30
|
+
return found;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* These variables written into the file: a line that names one is replaced where it stands, one
|
|
34
|
+
* that is not there yet goes at the end, and every other line — a comment, the app's own
|
|
35
|
+
* variables — is left exactly as it was. A file that does not exist is made readable by its owner
|
|
36
|
+
* alone, because what it holds is a key.
|
|
37
|
+
*/
|
|
38
|
+
export function writeDotenv(file, values) {
|
|
39
|
+
const lines = existsSync(file) ? readFileSync(file, "utf8").replace(/\n$/, "").split("\n") : [];
|
|
40
|
+
const left = new Map(Object.entries(values));
|
|
41
|
+
const written = lines.map((line) => {
|
|
42
|
+
const name = line.trim().replace(/^export\s+/, "").split("=")[0]?.trim();
|
|
43
|
+
const value = name === undefined ? undefined : left.get(name);
|
|
44
|
+
if (name === undefined || value === undefined)
|
|
45
|
+
return line;
|
|
46
|
+
left.delete(name);
|
|
47
|
+
return `${name}=${value}`;
|
|
48
|
+
});
|
|
49
|
+
for (const [name, value] of left)
|
|
50
|
+
written.push(`${name}=${value}`);
|
|
51
|
+
writeFileSync(file, `${written.join("\n")}\n`, { mode: 0o600 });
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Whether git keeps this file out of a commit: a key committed is a key published. Git answers it
|
|
55
|
+
* — every `.gitignore` up to the repository's root, and the global one — so the answer is the one
|
|
56
|
+
* a commit would act on. Outside a repository, or with no git at all, nothing can commit it.
|
|
57
|
+
*/
|
|
58
|
+
export function ignoredByGit(file) {
|
|
59
|
+
const asked = spawnSync("git", ["check-ignore", "-q", file], { cwd: dirname(file), stdio: "ignore" });
|
|
60
|
+
// 0 ignored · 1 not ignored · 128 not a repository; an error is no git on this machine.
|
|
61
|
+
return asked.error !== undefined || asked.status !== 1;
|
|
62
|
+
}
|
|
63
|
+
function unquoted(value) {
|
|
64
|
+
const quote = value[0];
|
|
65
|
+
if ((quote === '"' || quote === "'") && value.length >= 2 && value.endsWith(quote))
|
|
66
|
+
return value.slice(1, -1);
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=dotenv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dotenv.js","sourceRoot":"","sources":["../../src/cli/dotenv.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAElH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC;AAE7B,kGAAkG;AACl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