@deepagents/context 0.37.1 → 0.38.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 +1 -1
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +2 -2
- package/dist/index.js +69 -47
- package/dist/index.js.map +2 -2
- package/dist/lib/engine.d.ts.map +1 -1
- package/dist/lib/fragments/message/user.d.ts +4 -2
- package/dist/lib/fragments/message/user.d.ts.map +1 -1
- package/dist/lib/fragments/reminders/temporal/predicates.d.ts +1 -0
- package/dist/lib/fragments/reminders/temporal/predicates.d.ts.map +1 -1
- package/dist/lib/fragments/reminders/temporal/reminder.d.ts +1 -5
- package/dist/lib/fragments/reminders/temporal/reminder.d.ts.map +1 -1
- package/dist/lib/sandbox/routing-sandbox.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1313,7 +1313,7 @@ function reminder(textOrFragment, options) {
|
|
|
1313
1313
|
if (typeof text === "string") {
|
|
1314
1314
|
assertReminderText(text);
|
|
1315
1315
|
}
|
|
1316
|
-
const asPart = options?.asPart ??
|
|
1316
|
+
const asPart = options?.asPart ?? false;
|
|
1317
1317
|
if (options && "when" in options && options.when) {
|
|
1318
1318
|
return {
|
|
1319
1319
|
name: "reminder",
|
|
@@ -2893,6 +2893,7 @@ var ContextEngine = class _ContextEngine {
|
|
|
2893
2893
|
content: plainText,
|
|
2894
2894
|
lastMessageAt,
|
|
2895
2895
|
lastMessage,
|
|
2896
|
+
currentMessage: original,
|
|
2896
2897
|
chat: this.#chatData,
|
|
2897
2898
|
usage,
|
|
2898
2899
|
branch: this.#branchName,
|
|
@@ -4432,8 +4433,7 @@ function getLocaleFromMessage(message2) {
|
|
|
4432
4433
|
}
|
|
4433
4434
|
function resolveTz(options, ctx) {
|
|
4434
4435
|
if (options?.tz) return options.tz;
|
|
4435
|
-
|
|
4436
|
-
return locale?.timeZone ?? "UTC";
|
|
4436
|
+
return getLocaleFromMessage(ctx.currentMessage)?.timeZone ?? getLocaleFromMessage(ctx.lastMessage)?.timeZone ?? "UTC";
|
|
4437
4437
|
}
|
|
4438
4438
|
function toDateParts(date, tz) {
|
|
4439
4439
|
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
@@ -4581,7 +4581,7 @@ function dateReminder(options) {
|
|
|
4581
4581
|
return `${diff}Date: ${currentDate}
|
|
4582
4582
|
Day of Week: ${currentDay}`;
|
|
4583
4583
|
},
|
|
4584
|
-
{ when: dayChanged(options), asPart:
|
|
4584
|
+
{ when: dayChanged(options), asPart: false }
|
|
4585
4585
|
);
|
|
4586
4586
|
}
|
|
4587
4587
|
function timeReminder(options) {
|
|
@@ -4599,7 +4599,7 @@ function timeReminder(options) {
|
|
|
4599
4599
|
}
|
|
4600
4600
|
return `${diff}Time: ${currentTime}`;
|
|
4601
4601
|
},
|
|
4602
|
-
{ when: hourChanged(options), asPart:
|
|
4602
|
+
{ when: hourChanged(options), asPart: false }
|
|
4603
4603
|
);
|
|
4604
4604
|
}
|
|
4605
4605
|
function monthReminder(options) {
|
|
@@ -4617,7 +4617,7 @@ function monthReminder(options) {
|
|
|
4617
4617
|
}
|
|
4618
4618
|
return `${diff}Month: ${currentMonth}`;
|
|
4619
4619
|
},
|
|
4620
|
-
{ when: monthChanged(options), asPart:
|
|
4620
|
+
{ when: monthChanged(options), asPart: false }
|
|
4621
4621
|
);
|
|
4622
4622
|
}
|
|
4623
4623
|
function yearReminder(options) {
|
|
@@ -4635,7 +4635,7 @@ function yearReminder(options) {
|
|
|
4635
4635
|
}
|
|
4636
4636
|
return `${diff}Year: ${currentYear}`;
|
|
4637
4637
|
},
|
|
4638
|
-
{ when: yearChanged(options), asPart:
|
|
4638
|
+
{ when: yearChanged(options), asPart: false }
|
|
4639
4639
|
);
|
|
4640
4640
|
}
|
|
4641
4641
|
function seasonReminder(options) {
|
|
@@ -4653,36 +4653,30 @@ function seasonReminder(options) {
|
|
|
4653
4653
|
}
|
|
4654
4654
|
return `${diff}Season: ${currentSeason}`;
|
|
4655
4655
|
},
|
|
4656
|
-
{ when: seasonChanged(options), asPart:
|
|
4656
|
+
{ when: seasonChanged(options), asPart: false }
|
|
4657
4657
|
);
|
|
4658
4658
|
}
|
|
4659
|
-
function localeReminder(
|
|
4660
|
-
const language = options?.language ?? "English (US)";
|
|
4661
|
-
const timeZone = options?.timeZone ?? "UTC";
|
|
4659
|
+
function localeReminder() {
|
|
4662
4660
|
const whenFn = (ctx) => {
|
|
4663
|
-
const
|
|
4664
|
-
if (!
|
|
4665
|
-
|
|
4661
|
+
const current = getLocaleFromMessage(ctx.currentMessage);
|
|
4662
|
+
if (!current) return false;
|
|
4663
|
+
const last = getLocaleFromMessage(ctx.lastMessage);
|
|
4664
|
+
if (!last) return true;
|
|
4665
|
+
return current.language !== last.language || current.timeZone !== last.timeZone;
|
|
4666
4666
|
};
|
|
4667
4667
|
return reminder(
|
|
4668
4668
|
(ctx) => {
|
|
4669
|
-
const
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
}
|
|
4677
|
-
|
|
4678
|
-
text: `${diff}Language: ${language}
|
|
4679
|
-
Timezone: ${timeZone}`,
|
|
4680
|
-
metadata: {
|
|
4681
|
-
[LOCALE_METADATA_KEY]: { language, timeZone }
|
|
4682
|
-
}
|
|
4683
|
-
};
|
|
4669
|
+
const current = getLocaleFromMessage(ctx.currentMessage);
|
|
4670
|
+
if (!current) return "";
|
|
4671
|
+
const last = getLocaleFromMessage(ctx.lastMessage);
|
|
4672
|
+
const diff = last ? formatDiff([
|
|
4673
|
+
diffLine("language", last.language, current.language),
|
|
4674
|
+
diffLine("timezone", last.timeZone, current.timeZone)
|
|
4675
|
+
]) : "";
|
|
4676
|
+
return `${diff}Language: ${current.language}
|
|
4677
|
+
Timezone: ${current.timeZone}`;
|
|
4684
4678
|
},
|
|
4685
|
-
{ when: whenFn, asPart:
|
|
4679
|
+
{ when: whenFn, asPart: false }
|
|
4686
4680
|
);
|
|
4687
4681
|
}
|
|
4688
4682
|
function temporalReminder(options) {
|
|
@@ -6332,11 +6326,10 @@ function createShallowRouter(backend, ext, cwd) {
|
|
|
6332
6326
|
executeCommand: async (raw) => {
|
|
6333
6327
|
const preHook = ext.onBeforeBashCall ? (await ext.onBeforeBashCall({ command: raw })).command : raw;
|
|
6334
6328
|
let transformed;
|
|
6335
|
-
let
|
|
6329
|
+
let dispatch;
|
|
6336
6330
|
try {
|
|
6337
6331
|
transformed = ext.plugins.length > 0 ? transformer.transform(preHook).script : preHook;
|
|
6338
|
-
|
|
6339
|
-
tokens = firstCmd?.type === "SimpleCommand" ? tokenizeFirstCommand(transformed) : [];
|
|
6332
|
+
dispatch = extractDispatchTarget(parse(transformed), cwd);
|
|
6340
6333
|
} catch (err) {
|
|
6341
6334
|
return {
|
|
6342
6335
|
stdout: "",
|
|
@@ -6345,12 +6338,12 @@ function createShallowRouter(backend, ext, cwd) {
|
|
|
6345
6338
|
exitCode: 2
|
|
6346
6339
|
};
|
|
6347
6340
|
}
|
|
6348
|
-
const [name, ...args] = tokens;
|
|
6341
|
+
const [name, ...args] = dispatch?.tokens ?? [];
|
|
6349
6342
|
const cmd = name ? byName.get(name) : void 0;
|
|
6350
6343
|
if (cmd) {
|
|
6351
6344
|
return cmd.handler(args, {
|
|
6352
6345
|
sandbox: backend,
|
|
6353
|
-
cwd,
|
|
6346
|
+
cwd: dispatch?.cwd ?? cwd,
|
|
6354
6347
|
env: ext.env,
|
|
6355
6348
|
stdin: ""
|
|
6356
6349
|
});
|
|
@@ -6359,20 +6352,49 @@ function createShallowRouter(backend, ext, cwd) {
|
|
|
6359
6352
|
}
|
|
6360
6353
|
};
|
|
6361
6354
|
}
|
|
6362
|
-
function
|
|
6363
|
-
|
|
6364
|
-
const
|
|
6365
|
-
if (
|
|
6366
|
-
if (
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6355
|
+
function extractDispatchTarget(ast, defaultCwd) {
|
|
6356
|
+
if (ast.statements.length !== 1) return null;
|
|
6357
|
+
const statement = ast.statements[0];
|
|
6358
|
+
if (statement.background) return null;
|
|
6359
|
+
if (statement.operators.length === 0 && statement.pipelines.length === 1) {
|
|
6360
|
+
const tokens = tokenizeSimplePipeline(statement.pipelines[0]);
|
|
6361
|
+
return tokens ? { tokens, cwd: defaultCwd } : null;
|
|
6362
|
+
}
|
|
6363
|
+
if (statement.operators.length === 1 && statement.operators[0] === "&&" && statement.pipelines.length === 2) {
|
|
6364
|
+
const cd = simpleCommandFromPipeline(statement.pipelines[0]);
|
|
6365
|
+
const cdCwd = readCdTarget(cd);
|
|
6366
|
+
if (!cdCwd) return null;
|
|
6367
|
+
const tokens = tokenizeSimplePipeline(statement.pipelines[1]);
|
|
6368
|
+
return tokens ? { tokens, cwd: cdCwd } : null;
|
|
6369
|
+
}
|
|
6370
|
+
return null;
|
|
6371
|
+
}
|
|
6372
|
+
function simpleCommandFromPipeline(pipeline) {
|
|
6373
|
+
if (!pipeline) return null;
|
|
6374
|
+
if (pipeline.negated || pipeline.timed || pipeline.commands.length !== 1) {
|
|
6375
|
+
return null;
|
|
6376
|
+
}
|
|
6377
|
+
const command = pipeline.commands[0];
|
|
6378
|
+
return command?.type === "SimpleCommand" ? command : null;
|
|
6379
|
+
}
|
|
6380
|
+
function readCdTarget(command) {
|
|
6381
|
+
if (!command) return null;
|
|
6382
|
+
if (command.redirections.length > 0 || command.args.length !== 1) {
|
|
6383
|
+
return null;
|
|
6384
|
+
}
|
|
6385
|
+
const name = asStaticWordText(command.name);
|
|
6386
|
+
if (name !== "cd") return null;
|
|
6387
|
+
return asStaticWordText(command.args[0]);
|
|
6388
|
+
}
|
|
6389
|
+
function tokenizeSimplePipeline(pipeline) {
|
|
6390
|
+
const command = simpleCommandFromPipeline(pipeline);
|
|
6391
|
+
if (!command || command.redirections.length > 0) return null;
|
|
6392
|
+
const name = asStaticWordText(command.name);
|
|
6393
|
+
if (!name) return null;
|
|
6372
6394
|
const args = [];
|
|
6373
|
-
for (const arg of
|
|
6395
|
+
for (const arg of command.args) {
|
|
6374
6396
|
const text = asStaticWordText(arg);
|
|
6375
|
-
if (text == null) return
|
|
6397
|
+
if (text == null) return null;
|
|
6376
6398
|
args.push(text);
|
|
6377
6399
|
}
|
|
6378
6400
|
return [name, ...args];
|