@misterscan/sesi 1.1.1
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 +21 -0
- package/README.md +191 -0
- package/bin/sesi.js +56 -0
- package/dist/ai-runtime.d.ts +15 -0
- package/dist/ai-runtime.d.ts.map +1 -0
- package/dist/ai-runtime.js +214 -0
- package/dist/ai-runtime.js.map +1 -0
- package/dist/builtins.d.ts +7 -0
- package/dist/builtins.d.ts.map +1 -0
- package/dist/builtins.js +473 -0
- package/dist/builtins.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/interpreter.d.ts +36 -0
- package/dist/interpreter.d.ts.map +1 -0
- package/dist/interpreter.js +495 -0
- package/dist/interpreter.js.map +1 -0
- package/dist/lexer.d.ts +26 -0
- package/dist/lexer.d.ts.map +1 -0
- package/dist/lexer.js +340 -0
- package/dist/lexer.js.map +1 -0
- package/dist/parser.d.ts +55 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +1022 -0
- package/dist/parser.js.map +1 -0
- package/dist/types.d.ts +304 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +63 -0
- package/dist/types.js.map +1 -0
- package/docs/ARCHITECTURE.md +430 -0
- package/docs/BUILTINS.md +577 -0
- package/docs/COMPARISON.md +334 -0
- package/docs/DISTRIBUTED_SYSTEMS.md +71 -0
- package/docs/IMAGE_GENERATION.md +76 -0
- package/docs/IMPLEMENTATION_SUMMARY.md +533 -0
- package/docs/QUICKSTART.md +351 -0
- package/docs/README.md +191 -0
- package/docs/ROADMAP.md +408 -0
- package/docs/SPECIFICATION.md +462 -0
- package/docs/SYSTEMS_REASONING.md +522 -0
- package/examples/01_hello.sesi +2 -0
- package/examples/02_variables.sesi +11 -0
- package/examples/03_functions.sesi +6 -0
- package/examples/04_conditionals.sesi +6 -0
- package/examples/05_loops.sesi +12 -0
- package/examples/06_arrays_objects.sesi +18 -0
- package/examples/07_prompts.sesi +10 -0
- package/examples/08_model_call.sesi +5 -0
- package/examples/09_structured_output.sesi +7 -0
- package/examples/10_code_generation.sesi +5 -0
- package/examples/11_memory_conversation.sesi +16 -0
- package/examples/12_classification.sesi +8 -0
- package/examples/13_data_pipeline.sesi +35 -0
- package/examples/14_folder_explainer.sesi +58 -0
- package/examples/15_image_generation.sesi +17 -0
- package/main/atm_deposit.sesi +37 -0
- package/main/atm_withdraw.sesi +37 -0
- package/main/data.txt +1 -0
- package/main/math_aggregator.sesi +15 -0
- package/main/math_generator.sesi +7 -0
- package/main/math_processor.sesi +23 -0
- package/main/orchestrator.sesi +15 -0
- package/main/playground.sesi +1 -0
- package/main/setup_swarm.sesi +5 -0
- package/main/start.sesi +13 -0
- package/main/tax_calculator.sesi +15 -0
- package/main/tests/compare.sesi +23 -0
- package/main/tests/compare.ts +104 -0
- package/main/tests/debug.sesi +1 -0
- package/main/tests/demo.sesi +24 -0
- package/main/tests/primitive_validation.sesi +18 -0
- package/main/tests/test_connection.sesi +4 -0
- package/main/tests/test_failure_debug.sesi +2 -0
- package/main/tests/test_image.sesi +3 -0
- package/main/tests/test_parser_config.sesi +2 -0
- package/main/tests/test_syntax.sesi +3 -0
- package/main/tests/test_tool_call.sesi +14 -0
- package/main/tests/try.sesi +7 -0
- package/main/vault.sesi +15 -0
- package/package.json +50 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Example 14: Folder Explainer using native list_dir
|
|
2
|
+
// Requires GEMINI_API_KEY environment variable
|
|
3
|
+
|
|
4
|
+
let targetDir = "docs"
|
|
5
|
+
let files = list_dir(targetDir)
|
|
6
|
+
if type(files) == "null" {print "Error: Could not list directory" targetDir} else {print "Analyzing directory:" targetDir}
|
|
7
|
+
print "Files found in directory:" len(files)
|
|
8
|
+
let reports = []
|
|
9
|
+
fn analyzeFile(fullPath: string) -> object {
|
|
10
|
+
try
|
|
11
|
+
{let source = read_file(fullPath)
|
|
12
|
+
return structured_output({fileName: string, summary: string, complexity: string})(model("gemini-3.1-flash-lite") {"temperature": 0.2} {"Analyze this file and summarize its purpose. Return JSON with fileName, summary, and complexity (low/medium/high). File path: " fullPath " Contents: " source})}
|
|
13
|
+
catch (e)
|
|
14
|
+
{return {"fileName": fullPath, "summary": "Failed to read or analyze file", "complexity": "unknown"}}}
|
|
15
|
+
for file in files {
|
|
16
|
+
let fullPath = targetDir + "/" + file
|
|
17
|
+
let parts = split(file, ".")
|
|
18
|
+
if len(parts) > 1 {
|
|
19
|
+
let ext = parts[len(parts) - 1]
|
|
20
|
+
if ext == "md" {
|
|
21
|
+
print "Analyzing:" fullPath
|
|
22
|
+
let report = analyzeFile(fullPath)
|
|
23
|
+
push(reports, report)
|
|
24
|
+
print "Summary:" report["summary"]
|
|
25
|
+
print "Complexity:" report["complexity"]}}}
|
|
26
|
+
print "Generating folder overview..."
|
|
27
|
+
let folderSummary = structured_output({folderOverview: string, keyThemes: array<string>})(model("gemini-3.1-flash-lite") {"temperature": 0.2} {"You are summarizing the contents of a documentation folder based on file analyses. Return JSON with folderOverview and keyThemes. Analysis:" reports})
|
|
28
|
+
print "=== Final Folder Summary ==="
|
|
29
|
+
print "Overview:" folderSummary["folderOverview"]
|
|
30
|
+
print "Key Themes:" join(folderSummary["keyThemes"], ", ")
|
|
31
|
+
let overview = folderSummary["folderOverview"]
|
|
32
|
+
let themesStr = join(folderSummary["keyThemes"], ", ")
|
|
33
|
+
prompt mdBase {"# Folder Analysis Report
|
|
34
|
+
|
|
35
|
+
## Overview
|
|
36
|
+
" overview "
|
|
37
|
+
|
|
38
|
+
## Key Themes
|
|
39
|
+
" themesStr "
|
|
40
|
+
|
|
41
|
+
## File Details
|
|
42
|
+
"}
|
|
43
|
+
let finalMarkdown = mdBase
|
|
44
|
+
for report in reports {
|
|
45
|
+
let fname = report["fileName"]
|
|
46
|
+
let fsummary = report["summary"]
|
|
47
|
+
let comp = report["complexity"]
|
|
48
|
+
prompt fileEntry {"### " fname "
|
|
49
|
+
**Complexity**: " comp "
|
|
50
|
+
|
|
51
|
+
**Summary**: " fsummary "
|
|
52
|
+
|
|
53
|
+
"}
|
|
54
|
+
finalMarkdown = finalMarkdown + fileEntry
|
|
55
|
+
let outPath = "folder_analysis.md"
|
|
56
|
+
write_file(outPath, finalMarkdown)
|
|
57
|
+
print "Wrote analysis to" outPath
|
|
58
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Sesi Example: Batch Image Asset Generation
|
|
2
|
+
// Demonstrates how to use in a practical workflow with directories.
|
|
3
|
+
|
|
4
|
+
let outputDir = "assets/products/"
|
|
5
|
+
make_dir(outputDir)
|
|
6
|
+
let products = ["coffee_mug", "desk_lamp", "notebook"]
|
|
7
|
+
for product in products
|
|
8
|
+
{print "Generating asset for:" product
|
|
9
|
+
prompt request {"A clean studio presentation photograph of a " product " on a solid white background."}
|
|
10
|
+
prompt filename { outputDir product ".png" }
|
|
11
|
+
try
|
|
12
|
+
{let imageData = image("gemini-3.1-flash-image-preview") {"ratio": '1:1', "size": "1K"} {request}
|
|
13
|
+
let success = write_image(filename, imageData)
|
|
14
|
+
if success {print "Saved:" filename}}
|
|
15
|
+
catch (e) {print "Failed processing" product ":"
|
|
16
|
+
print e}}
|
|
17
|
+
print "Asset generation complete."
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
let id = "Dep_" + str(time()) + "_" + str(random())
|
|
2
|
+
let locked = true
|
|
3
|
+
while locked {
|
|
4
|
+
let status = "error"
|
|
5
|
+
try {
|
|
6
|
+
status = read_file("bank/lock.txt")
|
|
7
|
+
} catch (e) {
|
|
8
|
+
status = "error"
|
|
9
|
+
}
|
|
10
|
+
if status == "unlocked" {
|
|
11
|
+
try {
|
|
12
|
+
write_file("bank/lock.txt", id)
|
|
13
|
+
let i = 0
|
|
14
|
+
while i < 500 {
|
|
15
|
+
i = i + 1
|
|
16
|
+
}
|
|
17
|
+
if read_file("bank/lock.txt") == id {
|
|
18
|
+
locked = false
|
|
19
|
+
}
|
|
20
|
+
} catch (e) {
|
|
21
|
+
status = "error"
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
let j = 0
|
|
25
|
+
while j < 1000 {
|
|
26
|
+
j = j + 1
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
write_file("bank/balance.txt", str(num(read_file("bank/balance.txt")) + 100))
|
|
32
|
+
write_file("bank/done_count.txt", str(num(read_file("bank/done_count.txt")) + 1))
|
|
33
|
+
write_file("bank/lock.txt", "unlocked")
|
|
34
|
+
print id + ": Success"
|
|
35
|
+
} catch (e) {
|
|
36
|
+
write_file("bank/lock.txt", "unlocked")
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
let id = "With_" + str(time()) + "_" + str(random())
|
|
2
|
+
let locked = true
|
|
3
|
+
while locked {
|
|
4
|
+
let status = "error"
|
|
5
|
+
try {
|
|
6
|
+
status = read_file("bank/lock.txt")
|
|
7
|
+
} catch (e) {
|
|
8
|
+
status = "error"
|
|
9
|
+
}
|
|
10
|
+
if status == "unlocked" {
|
|
11
|
+
try {
|
|
12
|
+
write_file("bank/lock.txt", id)
|
|
13
|
+
let i = 0
|
|
14
|
+
while i < 500 {
|
|
15
|
+
i = i + 1
|
|
16
|
+
}
|
|
17
|
+
if read_file("bank/lock.txt") == id {
|
|
18
|
+
locked = false
|
|
19
|
+
}
|
|
20
|
+
} catch (e) {
|
|
21
|
+
status = "error"
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
let j = 0
|
|
25
|
+
while j < 1000 {
|
|
26
|
+
j = j + 1
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
write_file("bank/balance.txt", str(num(read_file("bank/balance.txt")) - 50))
|
|
32
|
+
write_file("bank/done_count.txt", str(num(read_file("bank/done_count.txt")) + 1))
|
|
33
|
+
write_file("bank/lock.txt", "unlocked")
|
|
34
|
+
print id + ": Success"
|
|
35
|
+
} catch (e) {
|
|
36
|
+
write_file("bank/lock.txt", "unlocked")
|
|
37
|
+
}
|
package/main/data.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Project X Status: Delayed. Reason: Scope creep. Priority: High.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Math Swarm: Aggregator
|
|
2
|
+
print "📊 Aggregator: Waiting for primes..."
|
|
3
|
+
let input = ""
|
|
4
|
+
while input == "" {input = read_file("swarm/primes.txt")}
|
|
5
|
+
let primes = split(input, ",")
|
|
6
|
+
let sum = 0
|
|
7
|
+
for pStr in primes {
|
|
8
|
+
if pStr != "" {
|
|
9
|
+
sum = sum + num(pStr)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
print "📊 Aggregator Result: "
|
|
13
|
+
print "Count: " + str(len(primes))
|
|
14
|
+
print "Sum: " + str(sum)
|
|
15
|
+
write_file("swarm/final.txt", "Count:" + str(len(primes)) + " Sum:" + str(sum))
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Math Swarm: Prime Processor
|
|
2
|
+
fn isPrime(n: number) -> bool {
|
|
3
|
+
if n <= 1 {return false}
|
|
4
|
+
let i = 2
|
|
5
|
+
while i * i <= n {
|
|
6
|
+
if n % i == 0 {return false}
|
|
7
|
+
i = i + 1
|
|
8
|
+
}
|
|
9
|
+
return true
|
|
10
|
+
}
|
|
11
|
+
print "🧬 Processor: Waiting for input..."
|
|
12
|
+
let input = ""
|
|
13
|
+
while input == "" {input = read_file("swarm/input.txt")}
|
|
14
|
+
let numbers = split(input, ",")
|
|
15
|
+
let primes = []
|
|
16
|
+
for nStr in numbers {
|
|
17
|
+
if nStr != "" {
|
|
18
|
+
let n = num(nStr)
|
|
19
|
+
if isPrime(n) {push(primes, nStr)}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
write_file("swarm/primes.txt", join(primes, ","))
|
|
23
|
+
print "Processor: Filtered " + str(len(primes)) + " primes."
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
print "🚀 Master: Launching 5-Agent Swarm..."
|
|
2
|
+
make_dir("bank")
|
|
3
|
+
write_file("bank/balance.txt", "1000")
|
|
4
|
+
write_file("bank/lock.txt", "unlocked")
|
|
5
|
+
write_file("bank/done_count.txt", "0")
|
|
6
|
+
spawn("main/atm_deposit.sesi")
|
|
7
|
+
spawn("main/atm_withdraw.sesi")
|
|
8
|
+
spawn("main/atm_deposit.sesi")
|
|
9
|
+
spawn("main/atm_withdraw.sesi")
|
|
10
|
+
spawn("main/atm_deposit.sesi")
|
|
11
|
+
let finished = false
|
|
12
|
+
while !finished {let countStr = read_file("bank/done_count.txt")
|
|
13
|
+
if countStr != "" {if num(countStr) >= 5 {finished = true}}}
|
|
14
|
+
print "🏦 Vault: Swarm Finished."
|
|
15
|
+
print "Final Balance:" read_file("bank/balance.txt")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Use this file to test controlled Sesi scripts, with logging and prompts to test model interactions.
|
package/main/start.sesi
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Welcome to your first Sesi program!
|
|
2
|
+
|
|
3
|
+
print "Initializing..."
|
|
4
|
+
|
|
5
|
+
// You can start with a simple calculation
|
|
6
|
+
let a = 10
|
|
7
|
+
let b = 5
|
|
8
|
+
print "Math check:" a + b
|
|
9
|
+
|
|
10
|
+
// Or jump straight into reasoning tasks
|
|
11
|
+
let topic = "building a new programming language"
|
|
12
|
+
let response = model("gemini-3.1-flash-lite") {"temperature": 0.3} {"Write a motivational 2-sentence intro about" topic}
|
|
13
|
+
print "Sesi:" response
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Complex Tax Calculator in Sesi
|
|
2
|
+
fn calculate_income_tax(income: number, dependents: number) -> number
|
|
3
|
+
{let standard_deduction = 14600
|
|
4
|
+
let dependent_deduction = dependents * 2000
|
|
5
|
+
let taxable_income = income - standard_deduction - dependent_deduction
|
|
6
|
+
if taxable_income <= 0 {return 0}
|
|
7
|
+
let tax = 0
|
|
8
|
+
if taxable_income <= 11600 {tax = taxable_income * 0.10} else if taxable_income <= 47150 {tax = (11600 * 0.10) + ((taxable_income - 11600) * 0.12)} else if taxable_income <= 100525 {tax = (11600 * 0.10) + ((47150 - 11600) * 0.12) + ((taxable_income - 47150) * 0.22)} else {tax = (11600 * 0.10) + ((47150 - 11600) * 0.12) + ((100525 - 47150) * 0.22) + ((taxable_income - 100525) * 0.24)}
|
|
9
|
+
let self_employment_tax = income * 0.153
|
|
10
|
+
return tax + self_employment_tax}
|
|
11
|
+
let income = 85000
|
|
12
|
+
let dependents = 2
|
|
13
|
+
let total_tax = calculate_income_tax(income, dependents)
|
|
14
|
+
print "Total calculated tax for income" income
|
|
15
|
+
print "Tax liability is:" total_tax
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Sesi Complex Data Pipeline
|
|
2
|
+
// Native structured outputs, tool calling, and memory.
|
|
3
|
+
|
|
4
|
+
fn escalateTicket(customerId: string, reason: string) {
|
|
5
|
+
print "ESCALATION: Customer" customerId "for" reason
|
|
6
|
+
return "Escalation logged."
|
|
7
|
+
}
|
|
8
|
+
memory processingLog {"Pipeline Start:"}
|
|
9
|
+
let rawFeedback = ["My account was charged twice for the pro plan! Fix this now!", "The new dashboard is really clean, great job team.", "I can't figure out how to export my data to CSV, it just spins."]
|
|
10
|
+
for feedback in rawFeedback
|
|
11
|
+
{processingLog = processingLog + "Processing:" + feedback
|
|
12
|
+
|
|
13
|
+
// 1. Structured Data Extraction (Native syntax)
|
|
14
|
+
let analysis = structured_output({sentiment: string, category: string, isUrgent: bool, summary: string})
|
|
15
|
+
(model("gemini-3.1-flash-lite") {"Analyze the customer feedback. Category should be Billing, UI, or Technical. Feedback: " feedback})
|
|
16
|
+
print "Result for:" analysis["summary"]
|
|
17
|
+
|
|
18
|
+
// 2. Conditional Tool Calling (Native syntax)
|
|
19
|
+
if analysis["isUrgent"]
|
|
20
|
+
{let resolution = tool_call(escalateTicket)(model("gemini-3.1-flash-lite") {"Call escalateTicket for customer '1234' with an exact reason based on: " feedback})
|
|
21
|
+
processingLog = processingLog + "Urgent action taken: " + resolution} else {processingLog = processingLog + "Logged routinely."}}
|
|
22
|
+
print "--- Final Processing Log ---"
|
|
23
|
+
print processingLog
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { GoogleGenAI, Type } from "@google/genai";
|
|
2
|
+
|
|
3
|
+
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
|
|
4
|
+
|
|
5
|
+
// The tool we want the model to call
|
|
6
|
+
function escalateTicket(customerId: string, reason: string): string {
|
|
7
|
+
console.log(`ESCALATION: Customer ${customerId} for ${reason}`);
|
|
8
|
+
return "Escalation logged.";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 1. Tool Declaration for the SDK (Boilerplate)
|
|
12
|
+
const escalateToolDeclaration = {
|
|
13
|
+
functionDeclarations: [
|
|
14
|
+
{
|
|
15
|
+
name: "escalateTicket",
|
|
16
|
+
description: "Escalate an urgent customer ticket",
|
|
17
|
+
parameters: {
|
|
18
|
+
type: Type.OBJECT,
|
|
19
|
+
properties: {
|
|
20
|
+
customerId: { type: Type.STRING, description: "ID of the customer" },
|
|
21
|
+
reason: { type: Type.STRING, description: "Reason for escalation" }
|
|
22
|
+
},
|
|
23
|
+
required: ["customerId", "reason"]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
async function processFeedback() {
|
|
30
|
+
let processingLog = "Pipeline Start:\n";
|
|
31
|
+
|
|
32
|
+
const rawFeedback = [
|
|
33
|
+
"My account was charged twice for the pro plan! Fix this now!",
|
|
34
|
+
"The new dashboard is really clean, great job team.",
|
|
35
|
+
"I can't figure out how to export my data to CSV, it just spins."
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
for (const feedback of rawFeedback) {
|
|
39
|
+
processingLog += `Processing: ${feedback}\n`;
|
|
40
|
+
|
|
41
|
+
// 2. Structured Data Extraction (Boilerplate Schema)
|
|
42
|
+
const schema = {
|
|
43
|
+
type: Type.OBJECT,
|
|
44
|
+
properties: {
|
|
45
|
+
sentiment: { type: Type.STRING },
|
|
46
|
+
category: { type: Type.STRING, description: "Billing, UI, or Technical" },
|
|
47
|
+
isUrgent: { type: Type.BOOLEAN },
|
|
48
|
+
summary: { type: Type.STRING }
|
|
49
|
+
},
|
|
50
|
+
required: ["sentiment", "category", "isUrgent", "summary"]
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const analysisResponse = await ai.models.generateContent({
|
|
54
|
+
model: "gemini-3.1-flash-lite",
|
|
55
|
+
contents: `Analyze the customer feedback. Category should be Billing, UI, or Technical.\nFeedback: ${feedback}`,
|
|
56
|
+
config: {
|
|
57
|
+
responseMimeType: "application/json",
|
|
58
|
+
responseSchema: schema,
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// 3. Manual JSON parsing and error handling
|
|
63
|
+
let analysis;
|
|
64
|
+
try {
|
|
65
|
+
analysis = JSON.parse(analysisResponse.text || "{}");
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error("Failed to parse JSON");
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(`Result for: ${analysis.summary}`);
|
|
72
|
+
|
|
73
|
+
// 4. Conditional Tool Calling & Response Handling
|
|
74
|
+
if (analysis.isUrgent) {
|
|
75
|
+
const escalationResponse = await ai.models.generateContent({
|
|
76
|
+
model: "gemini-3.1-flash-lite",
|
|
77
|
+
contents: `Call escalateTicket for customer '1234' with an exact reason based on:\n${feedback}`,
|
|
78
|
+
config: {
|
|
79
|
+
tools: [escalateToolDeclaration]
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// 5. Manual extraction of the function call from the response object
|
|
84
|
+
if (escalationResponse.functionCalls && escalationResponse.functionCalls.length > 0) {
|
|
85
|
+
const call = escalationResponse.functionCalls[0];
|
|
86
|
+
if (call.name === "escalateTicket") {
|
|
87
|
+
const args = call.args as any;
|
|
88
|
+
// Manual invocation of our local function using the args
|
|
89
|
+
const resolution = escalateTicket(args.customerId, args.reason);
|
|
90
|
+
processingLog += `Urgent action taken: ${resolution}\n`;
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
processingLog += `Urgent action failed to trigger tool.\n`;
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
processingLog += "Logged routinely.\n";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log("\n--- Final Processing Log ---");
|
|
101
|
+
console.log(processingLog);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
processFeedback().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{print "nested"}}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Sesi Demo Script
|
|
2
|
+
|
|
3
|
+
let userName = "Tony"
|
|
4
|
+
|
|
5
|
+
// Define a prompt for generating a quote
|
|
6
|
+
// NOTE: No '+' operator inside prompt block body
|
|
7
|
+
prompt quotePrompt {"Generate a short, motivational quote for " userName ". Only return the quote text."}
|
|
8
|
+
|
|
9
|
+
// Function to analyze sentiment using structured output
|
|
10
|
+
fn analyzeSentiment(text: string) {return structured_output({sentiment: string, score: number, explanation: string})(model("gemini-3.1-flash-lite") {"Analyze the sentiment of the following quote, score it, and give an explanation. Return the result as JSON:" text})}
|
|
11
|
+
print "--- Sesi Demo ---"
|
|
12
|
+
print "Hello," userName
|
|
13
|
+
|
|
14
|
+
// Call the model to get a quote
|
|
15
|
+
let quote = model("gemini-3.1-flash-lite") {quotePrompt}
|
|
16
|
+
print "Your quote for today:" quote
|
|
17
|
+
|
|
18
|
+
// Analyze the quote's sentiment
|
|
19
|
+
print "Analyzing sentiment..."
|
|
20
|
+
let analysis = analyzeSentiment(quote)
|
|
21
|
+
print "Sentiment:" analysis.sentiment
|
|
22
|
+
print "Score:" str(analysis.score)
|
|
23
|
+
print "Explanation:" analysis.explanation
|
|
24
|
+
print "Done."
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Systems Primitive Validation Script
|
|
2
|
+
print "--- Sesi Primitive Validation ---"
|
|
3
|
+
|
|
4
|
+
// 1. to_json test
|
|
5
|
+
let data = {"key": "value", "items": [1, 2, 3]}
|
|
6
|
+
let json = to_json(data)
|
|
7
|
+
print "to_json output:"
|
|
8
|
+
print json
|
|
9
|
+
|
|
10
|
+
// 2. Side-effect function test (No return)
|
|
11
|
+
let state = "initial"
|
|
12
|
+
fn update_state(new_val) {state = new_val}
|
|
13
|
+
print "State before:" state
|
|
14
|
+
update_state("updated")
|
|
15
|
+
print "State after:" state
|
|
16
|
+
|
|
17
|
+
// 3. Sequential string test (No +)
|
|
18
|
+
print "Final Status:" "Validation Complete"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Tool Call Demo
|
|
2
|
+
// This script lets the AI decide what to log.
|
|
3
|
+
|
|
4
|
+
memory discoveries {"Discoveries:"}
|
|
5
|
+
fn recordDiscovery(item: string) {print "Recording discovery..."
|
|
6
|
+
discoveries = discoveries + "- " + item}
|
|
7
|
+
print "AI is deciding what to record..."
|
|
8
|
+
recordDiscovery
|
|
9
|
+
|
|
10
|
+
// The AI will call recordDiscovery with a summary of its findings
|
|
11
|
+
// We use the 'Most capable' model as suggested by the docs
|
|
12
|
+
tool_call(recordDiscovery)(model("gemini-3.1-flash-lite") {"temperature": 0} {"Analyze the file src/interpreter.ts and record one major architectural pattern you find." "Source code snippet: "read_file("src/interpreter.ts")})
|
|
13
|
+
print "--- Final Log:"
|
|
14
|
+
print discoveries
|
package/main/vault.sesi
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Sesi Bank: Vault & Audit
|
|
2
|
+
// This script initializes the balance and lock state.
|
|
3
|
+
|
|
4
|
+
fn init() {
|
|
5
|
+
print "🏦 Vault: Initializing bank database..."
|
|
6
|
+
write_file("bank/balance.txt", "1000")
|
|
7
|
+
write_file("bank/lock.txt", "unlocked")
|
|
8
|
+
print "Vault: System Ready. Initial Balance: 1000"
|
|
9
|
+
}
|
|
10
|
+
fn audit() {
|
|
11
|
+
let balance = read_file("bank/balance.txt")
|
|
12
|
+
print "🏦 Vault Audit: Final Balance is: " + balance
|
|
13
|
+
}
|
|
14
|
+
make_dir("bank")
|
|
15
|
+
init()
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@misterscan/sesi",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Sesi: A High-Performance Systems Language",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"sesi": "bin/sesi.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"bin",
|
|
12
|
+
"docs",
|
|
13
|
+
"examples",
|
|
14
|
+
"main"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"lint": "npx eslint --fix",
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"dev": "npm run lint &&dotenvx run -- npm run build --watch",
|
|
20
|
+
"test": "npx ts-node tests/basic.test.ts",
|
|
21
|
+
"test:watch": "npm run lint && npx ts-node tests/basic.test.ts --watch",
|
|
22
|
+
"build:exe": "npx pkg . --targets node18-win-x64,node18-macos-x64,node18-linux-x64 --out-path releases",
|
|
23
|
+
"repl": "node dist/repl.js",
|
|
24
|
+
"example": "node --no-deprecation example.js",
|
|
25
|
+
"example:ai": "node --no-deprecation example-ai.js",
|
|
26
|
+
"example:all": "bin/sesi.js examples.sesi"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"ai",
|
|
30
|
+
"language",
|
|
31
|
+
"programming",
|
|
32
|
+
"gemini",
|
|
33
|
+
"interpreter"
|
|
34
|
+
],
|
|
35
|
+
"author": "Sesi Community",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@dotenvx/dotenvx": "^1.65.0",
|
|
39
|
+
"@dotenvx/dotenvx-ops": "^0.45.3",
|
|
40
|
+
"@google/genai": "2.0.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@eslint/js": "^10.0.1",
|
|
44
|
+
"@types/node": "^25.7.0",
|
|
45
|
+
"eslint": "^10.3.0",
|
|
46
|
+
"globals": "^17.6.0",
|
|
47
|
+
"typescript": "6.0.3",
|
|
48
|
+
"typescript-eslint": "^8.59.3"
|
|
49
|
+
}
|
|
50
|
+
}
|